[Newbies] Re: pretty printing

nicolas cellier ncellier at ifrance.com
Tue Sep 30 19:50:31 UTC 2008


Bert Freudenberg a écrit :
> snip...
> 
> Well, #collect: is much more readable and concise, and might be 
> optimized for some sorts of collections.
> 
> In general it's good practice to use the most specific iteration method 
> available rather than emulating using #do: (and always think twice, no, 
> three times before using #to:do:).
> 
> - Bert -

Yes, very good hint.
Apart for implementing higher level message, there is mostly one reason 
to use to:do: and it is often a bad one (I abused of, myself):
It is used to optimize code with some sort of inlining that can 
eliminate creation of blocks and squeeze the cost of a few message sends...
The danger is to make code inexpressive, longer than necessary, and not 
extensible to some other collection class.
Let us not optimize code prematurely!

Nicolas



More information about the Beginners mailing list