<div dir="ltr">Just having refactored several hundred incidents of (expression evaluating to something) ifNotNil: [:something | ... ] into ifNotNilDo: [ :something | ] I think the saving of the temp var is the only gain.<br>
<br>But it is useful to have that keyword for many people, not all of whom necessarily share your hesitance in using parentheses :)<br><br>Now if certain compilers didn't inline ifNotNil: I could have made the block argument optional, at least for our application (thank goodness for extensions).<br>
<br>The horse seems to have left the barn, but if I knew yesterday I was going to be facing this problem I would have argued for a more elegant solution. Now it's just another example of the divergent thinking and stubbornness that keeps code from being easily moved from one Smalltalk implementation to another.<br>
<br>Speaking of which, namespaces are still a problem.<br><br><div class="gmail_quote">On Thu, Sep 25, 2008 at 2:35 AM, Andres Valloud <span dir="ltr"><<a href="mailto:andres.valloud@gmail.com">andres.valloud@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I am just wondering now... let's say one writes something like this:<br>
<br>
something ifNilDo: [:nilObject | nilObject doWhatever]<br>
<br>
This does not seem to make a lot of sense because if ifNilDo:<br>
evaluates the block, then the argument is known to be nil. So let's<br>
look at this one<br>
<br>
something ifNotNilDo: [:someObject | someObject doWhatever]<br>
<br>
Why is this actually useful? I am not saying it's not, but I am<br>
having trouble seeing the reason. Since the receiver is known at this<br>
time, then I'd be tempted to do something like this:<br>
<br>
something ifNotNilDo: [something doWhatever]<br>
<br>
and skip the block argument. One could say "ah but then this requires<br>
a temp var". However, expressions such as<br>
<br>
something blah ifNotNilDo: [:something | something doWhatever]<br>
<br>
are only possible to write without parentheses when "something blah"<br>
does not have keyword messages in it... which is something that I try<br>
to avoid as much as possible...<br>
<br>
Is this the only gain?<br>
<font color="#888888"><br>
Andres.<br>
</font><div><div></div><div class="Wj3C7c"><br>
<br>
On Mon, Sep 8, 2008 at 11:50 AM, Paolo Bonzini <<a href="mailto:bonzini@gnu.org">bonzini@gnu.org</a>> wrote:<br>
><br>
>>> ifNotEmptyDo: aBlock<br>
>>> ^self isEmpty ifTrue: [aBlock value: self]<br>
>><br>
>> That is still bizarre, if you ask me...<br>
><br>
> Uhm, indeed. Paste-o or bug!?<br>
><br>
>>> It certainly doesn't involve any sending of the message #do:.<br>
>><br>
>> No. I think Paolo meant that he would read it like that.<br>
>> It would feel to him as if a #do: iteration was implied.<br>
>> (I suspect this is what Paolo meant).<br>
><br>
> Yes, thanks for helping decyphering my messages. :-)<br>
><br>
> Paolo<br>
><br>
> _______________________________________________<br>
> ANSI-Smalltalk mailing list<br>
> <a href="mailto:ANSI-Smalltalk@lists.openskills.org">ANSI-Smalltalk@lists.openskills.org</a><br>
> <a href="http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk" target="_blank">http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk</a><br>
><br>
<br>
_______________________________________________<br>
ANSI-Smalltalk mailing list<br>
<a href="mailto:ANSI-Smalltalk@lists.openskills.org">ANSI-Smalltalk@lists.openskills.org</a><br>
<a href="http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk" target="_blank">http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk</a><br>
</div></div></blockquote></div><br></div>