[squeak-dev] Re: Why is Heap>>#species => Array?

Paolo Bonzini bonzini at gnu.org
Tue Feb 26 11:57:48 UTC 2008


> We spent a long time trying to find good names (and not just for these 
> methods).  As I recall, we rejected #copyEmpty because we felt that the 
> programmer might reasonably expect the result of #copyEmpty to be empty, 
> and, with Array for example,  it isn't going to be.

It's going to be empty in the sense that it is stuffed with nils -- 
that's as empty as an ArrayedCollection can get. :-)  However...

> Hence the more descriptive names.   They are mostly used internally, 
> where the extra length is no handicap.  On  the occasions when they are 
> used externally, the extra length is  a benefit.

... I agree with you (I was just pointing out the parallel with other 
dialects in case people wanted to explore their implementation).

>> As I said, it works for everything except #reverse and #collect: for 
>> which you can either use something like #copyEmptyForCollect, or 
>> resort to #species.
> 
> Why doesn't this work for #reversed? 

Because SortedCollection's #reverse returns an OrderedCollection, like 
#collect: does.

Paolo



More information about the Squeak-dev mailing list