[Newbies] Re: Re: Re: error trap

Klaus D. Witzel klaus.witzel at cobss.com
Mon Aug 14 08:04:24 UTC 2006


On Sun, 13 Aug 2006 18:31:23 +0200, Damien Cassou wrote:
> Klaus wrote:
>> Yes. And, into the other direction, even in good core methods one often  
>> finds things like
>>   ^ dict at: aKey ifAbsent: [nil]
>>  There seems to be a "natural" confusion between "object" value and  
>> block "value".

Perhaps I should add rules of thumb for when to *author* a block of code:

#1 - for a non local return like [^ nil]

#2 - for deferring a computation like [base raisedTo: bigInteger]

#3 - for parameterized "smart" logic like [:x :y | "do something with  
self, x and y"]

Anybody anything for #4 ?

Unfortunately there are, enforced by people who wrote the compiler, other  
rules (not many of them are for the thumb). For an example try a printIt on

  ^ true ifTrue: #a ifFalse: [false ifTrue: #b ifFalse: #c]

Again, a "natural" confusion between an object's value and a block's value.

/Klaus



More information about the Beginners mailing list