What to believe?

Dan Ingalls Dan at SqueakLand.org
Wed Jun 27 17:27:23 UTC 2007


>On Jun 27, 2007, at 9:14 , Blake wrote:
>
>>On Tue, 26 Jun 2007 23:54:39 -0700, Bert Freudenberg <bert at freudenbergs.de> wrote:
>>
>>>"ifTrue: aBlock" is short-hand for "ifTrue: trueBlock ifFalse: []". The value of an empty block is nil by definition. That's why True and False must return nil in #ifFalse: and #ifTrue:, respectively.
>>
>>So, lint is in this case un-short-handing.
>
>Right. As Andreas points out it is conceivable that some Smalltalk would redefine the meaning so this would be more portable, and it might be considered more readable because it spells out the other case explicitly, leaving no one to wonder about the return value.

I may be the one responsible for the shorthand here (but memory does not serve in this case).  In any event, I'll add that I agree with the lint point of view that any of these paired expressions should include the nil branch when evaluated for value (as in assignments, as arguments, and as return values).  The decompiler can recognize these cases, so I'd certainly agree with modifying the decompiler accordingly.  When only evaluated for effect, the shorthand is not only simpler, but it invariably matches the program as originally written, so that should be retained.

	- Dan



More information about the Squeak-dev mailing list