<div dir="ltr"><div>VA Smalltalk also has some *Do: methods that do not imply iteration, but they are few and&nbsp;relatively obscure&nbsp;(for the most part).&nbsp; I don&#39;t like them, but I am forced to live with them.&nbsp; I am definitely against adding any more selectors of their ilk -- either in our product or in the standard.</div>

<div><br clear="all">John O&#39;Keefe [|], Principal Smalltalk Architect, Instantiations Inc.<br><br><br></div>
<div class="gmail_quote">On Mon, Sep 8, 2008 at 7:26 AM, Paolo Bonzini <span dir="ltr">&lt;<a href="mailto:bonzini@gnu.org">bonzini@gnu.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div class="Ih2E3d"><br>&gt; I am now confused.<br>&gt; The actual code in Squeak is<br>&gt;<br>&gt; &nbsp; &nbsp; ifNotEmptyDo: aBlock<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; ^self isEmpty ifTrue: [aBlock value: self]<br>&gt;<br>&gt; It certainly doesn&#39;t involve any sending of the message #do:.<br>
<br></div>Which is all but intention revealing.<br>
<div class="Ih2E3d"><br>&gt; x isEmpty ifTrue: [x do: monadicBlock]<br>&gt;<br>&gt; would, if x is a collection, never do anything at all with monadicBlock.<br>&gt; I take it that this should have been<br>&gt;<br>&gt; x isEmpty ifFalse: [x do: monadicBlock]<br>
&gt;<br>&gt; and there is a name for that too: &nbsp;#do:.<br><br></div>Of course, but there is no existing name for #ifEmpty:ifNotEmptyDo:.<br>Moreover, if you have another message #ifEmpty:ifNotEmpty: there is no<br>hint that the two differ *in the arity of the second block*!<br>
<br>If there were to be methods like #ifEmpty:, you should have only these four:<br><br>&nbsp; #ifEmpty:<br>&nbsp; #ifNotEmpty:<br>&nbsp; #ifEmpty:ifNotEmpty:<br>&nbsp; #ifNotEmpty:ifEmpty:<br><br>plus possibly<br><br>&nbsp; #ifEmpty:ifNotEmptyDo: &nbsp; &nbsp; &nbsp; (passing the second block to #do:)<br>
&nbsp; #ifNotEmptyDo:ifEmpty:<br><br>Furthermore, all parameters of all six methods should have variable<br>arity, because unlike the nil/not-nil case, there are many empty<br>collections and you may want to know it even in the empty case. &nbsp;I agree<br>
that this is borderline -- I cannot think of a use case indeed, and most<br>of the time you&#39;ll use #ifEmpty: just as a guard for ^self.<br>
<div class="Ih2E3d"><br>&gt; VisualWorks also has an if*Do: method or two.<br>&gt; GeneralBindingReference&gt;&gt;ifDefinedDo:<br>&gt; has nothing to do with #do:.<br>&gt; WindowManager&gt;&gt;activeControllerProcessIfBlockedDo:<br>
&gt; also has nothing to do with #do:.<br><br></div>But no #ifDefined: and #activeControllerProcessIfBlocked:. &nbsp;I don&#39;t like<br>those names very much, but that&#39;s nothing compared to overloading &nbsp;&quot;Do:&quot;<br>
(which already has a well-known meaning in Smalltalk, i.e. &quot;iterate&quot;) to<br>mark arity.<br><font color="#888888"><br>Paolo<br></font>
<div>
<div></div>
<div class="Wj3C7c"><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>