The issue here is that the selector count seems to be defined with  
two types, one returning an object and the other returning an  
integer.  The compiler thinks it's the first one, and is the second  
one.  It gets an integer return, but treats it as an object.  The  
return value is 3, which is equivalent to the SmallInt value.  If you  
try this with an array of four elements, then you will get a crash  
instead.

The offending -count method seems to be in GSMemoryPanelEntry - I  
have absolutely no idea what this class is supposed to do.  It is  
incredibly bad form to define selectors with the same name but  
different types to others in the system (sometimes unavoidable with  
independently-developed libraries, but it certainly should not be  
happening with selectors declared in OpenStep classes) - you can turn  
on a GCC warning to do this, but it seems the GNUstep devs didn't,  
which is a shame since it can cause some very difficult to track down  
bugs in ObjC code too.

I'm not sure what the best solution is here.  I don't want to have to  
move the auto-boxing logic into runtime code, since this will come  
with a huge performance penalty, but it might be unavoidable.

Suggestions?

David

On 31 Jul 2008, at 08:43, Yen-Ju Chen wrote:

> I might miss something, but it seems that -count does not work
> properly in Smalltalk.
> Here is a short script for testing.
>
> NSObject subclass: SmalltalkTool
> [
>       run
>       [
>               |a|
>               a := {'1'. '2'. '3'.}.
>               a log.
>               a count log.
>       ]
> ]
>
> 'a count' return 1, but a is an array of 3 objects.
>
> Thanx.
>
> Yen-Ju
>
> _______________________________________________
> Etoile-dev mailing list
> [email protected]
> https://mail.gna.org/listinfo/etoile-dev


_______________________________________________
Etoile-dev mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-dev

Reply via email to