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

Andrew P. Black black at cs.pdx.edu
Tue Feb 26 08:36:43 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.

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.


On 23 Feb 2008, at 0:07, Paolo Bonzini wrote:

>>  We decided to uniformly use two methods, emptyCopyOfSize: and  
>> emptyCopyOfSameSize , to generate the new collections.   
>> emptyCopyOfSameSize was implemented as
>>     ^ self  emptyCopyOfSize: self size
>
> This is what other Smalltalk usually call #copyEmpty and #copyEmpty:.
>
> 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?

For collect, I agree, the new collection may not be of the same  
class, and thus should not be called a copy;  
#emptyCollectionForCollect:  or #emptyForCollect: would seem to be  
suggestive names.

Shouldn't #reverse (the imperative form of the verb) be a mutator?    
But I guess that's another issue

Professor Andrew P. Black
Department of Computer Science
Portland State University
+1 503 725 2411



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080226/23f7fe03/attachment.htm


More information about the Squeak-dev mailing list