[ENH] CollectionEnh-dgd

Scott Wallace scott.wallace at squeakland.org
Mon Sep 13 21:21:24 UTC 2004


Hi, Diego,

Worthy stuff!  But note the following...


(1)  Your #select:thenDo: is identical in implementation to our 
long-standing #select:thenCollect:


(2)  As for your other two (#collect:thenDo: and #reject:thenDo:), it 
seems to me that they're either slightly mis-named or else slightly 
mis-implemented.   Either the second-step should really be a *do* 
rather than a *collect*, or else the selector name should hint at the 
"collecting" nature of the final action.  (Or am I missing something 
here?)

Thus, for example, I would expect that a method named 
#collect:thenDo: would be implemented as follows:

collect: block1 thenDo: block2
     (self collect: block1) do: block2

or, if we retain your implementation, we might prefer to use a 
different selector, e.g.:

collect: block1 thenCollect: block2
     ^ (self collect: block1) collect: block2


... and similarly for the #reject: variant.

-----

When I first added #collect:thenSelect: and #select:thenCollect: to 
Squeak, back in 1996, there were some murmurings that these were not 
strictly necessary, but my justification for these was on 
"readability" grounds -- same argument as yours here -- and I feel 
that the fullness of time has justified those additions.

I feel similarly about your suggested additions, but let's get the 
selector names and the actual implementations more tightly correlated.


Cheers,

  -- Scott


At 8:07 PM +0200 9/13/04, DiegoGomezDeck at ConsultAr.com wrote:
>from preamble:
>
>"Change Set:		CollectionEnh-dgd
>Date:			13 September 2004
>Author:			Diego Gomez Deck
>
>New methods (#collect:thenDo: #reject:thenDo: #select:thenDo:) to
>improve readability in 3 of the most used idioms with collections.
>
>The current implementation is straight forward but it leaves space for
>(memory use) improvements (avoiding the creation of the temporary
>collection).
>
>"!
>
>Content-type: application/octet-stream
>Content-disposition: attachment;filename="CollectionEnh-dgd.cs.gz"
>
>Attachment converted: titanium:CollectionEnh-dgd.cs.gz (????/----) (000E0C89)




More information about the Squeak-dev mailing list