[ANSI-Smalltalk] Re: A list of interesting methods, ifNotNil:
Paolo Bonzini
bonzini at gnu.org
Sat Oct 4 08:21:15 BST 2008
>> It is also ironic that I find these names
>>
>>> 1) >>isNil: a0block (^self isNil ifTrue: [a0block value] ifFalse: [self])
>>> 2) >>notNil: a0block (^self isNil ifTrue: [nil] ifFalse: [a0block value])
>>> 3) >>nonNil: a1block (^self isNil ifTrue: [nil] ifFalse: [a1block value: self])
>>> 4) >>orIfNil: a0block (^self isNil ifTrue: [a0block value] ifFalse: [self])
>> to be totally non-intention revealing except the fourth -- the only one
>> which includes "If" in its name.
>
> ( Curiousity strikes. Is it a collision
> of multiples, or no discernable meaning
> at all, when you read those (my) selectors?
> )
#orIfNil: is clear: return this object or, if it is nil, the block.
(See the English compared with the keyword? That's the number-1 feature
of the Smalltalk grammar for me. As a non-native speaker, it is a
perfect balance between human and machine parsability).
The others seem either grammatically incorrect (#isNil: because the
sentence is terminated after "X is Y") or indistinguishable
(#notNil:/nonNil: which is another point in favor of variable-arity
blocks...).
Actually are #isNil: and #orIfNil: meant to be exactly the same?
Thanks for the interesting answer (though I snipped most of it).
Paolo
More information about the ANSI-Smalltalk
mailing list