<div dir="auto">#testMissingThenAdd:  ?</div><div class="gmail_extra"><br><div class="gmail_quote">On Jun 15, 2017 12:19 PM, "Eliot Miranda" <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Tobias,<div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 15, 2017 at 12:06 PM, Tobias Pape <span dir="ltr"><<a href="mailto:Das.Linux@gmx.de" target="_blank">Das.Linux@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div class="m_-7705585875473007961gmail-HOEnZb"><div class="m_-7705585875473007961gmail-h5"><br>
> On 15.06.2017, at 20:30, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>> wrote:<br>
><br>
> Hi Levente, Hi Chris,<br>
><br>
> On Wed, Jun 14, 2017 at 1:10 PM, Levente Uzonyi <<a href="mailto:leves@caesar.elte.hu" target="_blank">leves@caesar.elte.hu</a>> wrote:<br>
> On Wed, 14 Jun 2017, <a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a> wrote:<br>
><br>
> Eliot Miranda uploaded a new version of Collections to project The Trunk:<br>
> <a href="http://source.squeak.org/trunk/Collections-eem.756.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/trunk<wbr>/Collections-eem.756.mcz</a><br>
><br>
> ==================== Summary ====================<br>
><br>
> Name: Collections-eem.756<br>
> Author: eem<br>
> Time: 14 June 2017, 11:03:24.917631 am<br>
> UUID: 8d7c03bc-1cdb-44c7-9173-10d50c<wbr>0dae29<br>
> Ancestors: Collections-eem.755<br>
><br>
> Add SequenceableCollection>>withou<wbr>tDuplicates for a more elegant fix to MailMessage>>to:<br>
><br>
> =============== Diff against Collections-eem.755 ===============<br>
><br>
> Item was added:<br>
> + ----- Method: SequenceableCollection>>withou<wbr>tDuplicates (in category 'copying') -----<br>
> + withoutDuplicates<br>
> +       "Answer a copy of the receiver that preserves order but eliminates any duplicates."<br>
> +       | seen |<br>
> +       seen := Set new: self size.<br>
> +       ^self select: [:each|<br>
> +                                 (seen includes: each)<br>
> +                                       ifTrue: [false]<br>
> +                                       ifFalse: [seen add: each. true]]!<br>
><br>
> What a great opportunity to use #addNewElement::<br>
><br>
>         ^self select: [ :each | seen addNewElement: each ]<br>
><br>
> I love the functionality but I don't like the selector. It seems to imply that one must only add a new element.  So why not call this something like addIfAbsent: ?<br>
><br>
> Here are some suggestions.  Votes?<br>
> - don't change it; stick with addNewElement:<br>
> - addIfAbsent:<br>
> - ifAbsentAdd:<br>
> - ifMissingAdd:<br>
><br>
> I think I prefer ifAbsentAdd: cuz addIfAbsent: looks too much like a potential spelling error, and conflicts with typical ifAbsent: arguments supplying exception blocks.  But I could go with ifMissingAdd: because it is more distinctive.<br>
<br>
</div></div>Well, we do have<br>
<br>
        Collection>>addIfNotPresent:<br>
<br>
So why invent a new one?<br></blockquote><div><br></div><div>Because addIfNotPresent: answers its argument and we need one that answers whether the element was absent.  So alas addIfNotPresent: is not a suitable candidate.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
I think the important thing with #addNewElement: is that it returns *whether* it added a new element<br>
but then again it breaks the tradition of #add* returning its argument…<br>
<br>
a very clear and very strange one that would reveal that a boolean is returned would be #isAbsentAndIfSoAdd: …<br></blockquote><div><br></div><div>wasAbsentAdding: or ifWasAbsentAdding: would be less cumbersome but I like something snappier that people will remember.  ifMissingAdd: looks good because it doesn't conflict with the add*: methods answering their argument, and the ifMissing implies the answer is true if the element wasn't already present.</div><div><br></div><div>Stéphane, can you live with ifMissingAdd: ?  Chris?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Best regards<br>
        -Tobias<br><br>> _,,,^..^,,,_<br>
> best, Eliot<br></blockquote><div> </div></div><div class="m_-7705585875473007961gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>
<br><br>
<br></blockquote></div></div>