<div dir="ltr"><div>VA Smalltalk also has some *Do: methods that do not imply iteration, but they are few and relatively obscure (for the most part). I don't like them, but I am forced to live with them. 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'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"><<a href="mailto:bonzini@gnu.org">bonzini@gnu.org</a>></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>> I am now confused.<br>> The actual code in Squeak is<br>><br>> ifNotEmptyDo: aBlock<br>> ^self isEmpty ifTrue: [aBlock value: self]<br>><br>> It certainly doesn't involve any sending of the message #do:.<br>
<br></div>Which is all but intention revealing.<br>
<div class="Ih2E3d"><br>> x isEmpty ifTrue: [x do: monadicBlock]<br>><br>> would, if x is a collection, never do anything at all with monadicBlock.<br>> I take it that this should have been<br>><br>> x isEmpty ifFalse: [x do: monadicBlock]<br>
><br>> and there is a name for that too: #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> #ifEmpty:<br> #ifNotEmpty:<br> #ifEmpty:ifNotEmpty:<br> #ifNotEmpty:ifEmpty:<br><br>plus possibly<br><br> #ifEmpty:ifNotEmptyDo: (passing the second block to #do:)<br>
#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. I agree<br>
that this is borderline -- I cannot think of a use case indeed, and most<br>of the time you'll use #ifEmpty: just as a guard for ^self.<br>
<div class="Ih2E3d"><br>> VisualWorks also has an if*Do: method or two.<br>> GeneralBindingReference>>ifDefinedDo:<br>> has nothing to do with #do:.<br>> WindowManager>>activeControllerProcessIfBlockedDo:<br>
> also has nothing to do with #do:.<br><br></div>But no #ifDefined: and #activeControllerProcessIfBlocked:. I don't like<br>those names very much, but that's nothing compared to overloading "Do:"<br>
(which already has a well-known meaning in Smalltalk, i.e. "iterate") 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>