[ANSI-Smalltalk] Re: A list of interesting methods, ifNotNil:
Paolo Bonzini
bonzini at gnu.org
Sat Sep 27 09:39:53 BST 2008
cstb wrote:
> At 08:57 PM 9/25/2008, Andres wrote:
>> ...
>> I try not to use ifNil:/ifNotNil: as a conditional branch control
>> message because they do not behave the same as ifTrue:ifFalse:.
>
>
> Agreed.
>
> For that same reason, and several others,
> I'd rather we did *not* name these things
> using variations of the pattern
>
> #if{condition}:
>
> so that the sequence
>
> space-$i-$f
So you don't use ifTrue:ifFalse: to do
x := foo ifTrue: [1] ifFalse: [0].
?
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.
I think any decent standardization process of features that are already
"in the wild" should look at existing code, and historically the methods
were named #ifNil:ifNotNil:. They were in VA Smalltalk around ~1996
with an "abt" prefix (like #abtIfNil:ifNotNil:).
The "Do" part was added in Squeak only because they do not support
variable arity blocks, which could be added contextually.
Paolo
More information about the ANSI-Smalltalk
mailing list