What to believe?
Andreas Raab
andreas.raab at gmx.de
Wed Jun 27 07:02:46 UTC 2007
Bert Freudenberg wrote:
>> I guess if we're talking portability though, it might be a valid
>> question. I'm not sure the Smalltalk spec mandates that instances of
>> True and False must return nil.
>
> "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.
That is not necessarily the case. One can make an equally good argument
saying that "foo ifTrue:[...]" should expand to "foo ifTrue:[...]
ifFalse:[foo]" which is coincidentally true for ifNil:ifNotNil: and
*should* be true (and I'm glad we fixed this in Croquet) for
ifEmpty:ifNotEmpty:. In other words if it is the case that:
42 ifNil:[...] => 42
#(1 2 3) ifEmpty:[...] => #(1 2 3)
then it seems quite consistent to have
false ifTrue:[...] => false.
(not that I'm proposing to change this btw, since it would break a whole
bunch of stuff but it's perfectly consistent with other semantics that
are generally deemed "intuitive")
Cheers,
- Andreas
More information about the Squeak-dev
mailing list
|