<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&#39;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&#39;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">&lt;<a href="mailto:andres.valloud@gmail.com">andres.valloud@gmail.com</a>&gt;</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&#39;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. &nbsp;So let&#39;s<br>
look at this one<br>
<br>
something ifNotNilDo: [:someObject | someObject doWhatever]<br>
<br>
Why is this actually useful? &nbsp;I am not saying it&#39;s not, but I am<br>
having trouble seeing the reason. &nbsp;Since the receiver is known at this<br>
time, then I&#39;d be tempted to do something like this:<br>
<br>
something ifNotNilDo: [something doWhatever]<br>
<br>
and skip the block argument. &nbsp;One could say &quot;ah but then this requires<br>
a temp var&quot;. &nbsp;However, expressions such as<br>
<br>
something blah ifNotNilDo: [:something | something doWhatever]<br>
<br>
are only possible to write without parentheses when &quot;something blah&quot;<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 &lt;<a href="mailto:bonzini@gnu.org">bonzini@gnu.org</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt;&gt; &nbsp; &nbsp; ifNotEmptyDo: aBlock<br>
&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; ^self isEmpty ifTrue: [aBlock value: self]<br>
&gt;&gt;<br>
&gt;&gt; That is still bizarre, if you ask me...<br>
&gt;<br>
&gt; Uhm, indeed. &nbsp;Paste-o or bug!?<br>
&gt;<br>
&gt;&gt;&gt; It certainly doesn&#39;t involve any sending of the message #do:.<br>
&gt;&gt;<br>
&gt;&gt; No. I think Paolo meant that he would read it like that.<br>
&gt;&gt; It would feel to him as if a #do: iteration was implied.<br>
&gt;&gt; (I suspect this is what Paolo meant).<br>
&gt;<br>
&gt; Yes, thanks for helping decyphering my messages. :-)<br>
&gt;<br>
&gt; Paolo<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; ANSI-Smalltalk mailing list<br>
&gt; <a href="mailto:ANSI-Smalltalk@lists.openskills.org">ANSI-Smalltalk@lists.openskills.org</a><br>
&gt; <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>
&gt;<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>