ifTrue: ~~ ifNil:

Andres Valloud avalloud at entrypoint.com
Wed Apr 12 19:59:10 UTC 2000


Hi Stephan.

> > I just put the question for the sake of the completeness of the argument. It seemed odd to me that true ifFalse: [^#result] was nil, when true ifNil: [^#result] was true. At first sight, I felt both should be either nil xor anObject.
>
> The line
>         var _ true ifNil: [#undefined]
> doesn't make any sense and the more general line
>         var _ booleanExpression ifNil: [^#undefined]
> makes only sense for exception handling, because in normal case the
> booleanExpression cannot be nil.

Yes. I agree. It's like 1=2 ifTrue:... I insist I just put that forward for the sake of the completeness of the argument, not because it is practical to do that.

> The line
>         var _ booleanExpression ifNil: [#undefined]
> is a shortcut for
>         var _ booleanExpression.
>         var isNil ifTrue: [var _ #undefined].
> .
>
> Would it help to think of #butIfNil: if you read #ifNil: ?
> Then it would be (in mind)
>         var _ booleanExpression butIfNil: [#undefined].

Hah!!!... I really like the butIfNil: part better than ifNil:!!!

I'd like it to be clear that I am not interested in changing the name of ifNil:, and because of its behavior I just asked why it was that. butIfNil...

Oh well :).
Andres.





More information about the Squeak-dev mailing list