<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 15, 2017 at 1:22 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:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-"><br>
> On 15.06.2017, at 21:40, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br>
><br>
> Hi Tobias,<br>
><br>
</span><span class="gmail-">> On Thu, Jun 15, 2017 at 12:32 PM, Tobias Pape <<a href="mailto:Das.Linux@gmx.de">Das.Linux@gmx.de</a>> wrote:<br>
><br>
> > On 15.06.2017, at 21:22, Chris Cunningham <<a href="mailto:cunningham.cb@gmail.com">cunningham.cb@gmail.com</a>> wrote:<br>
> ><br>
> > #testMissingThenAdd:  ?<br>
> ><br>
><br>
> #isAdding:<br>
> #ingests:<br>
><br>
> #wasAbsentButNowIsPresent:<br>
><br>
> (just rambling…)<br>
><br>
> I like added:.  Its concise, accurate and reads nicely:<br></span></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-"><br>
</span>Ok, but then maybe #addedNew: ? So as we know more than just an adding operation succeeded… :)<br></blockquote><div><br></div><div>So it reads:</div><div><span style="color:rgb(80,0,80);font-size:12.8px"><br></span></div><div><span style="color:rgb(80,0,80);font-size:12.8px">^self select: [:each| seen addedNew: each]</span> </div><div><br></div><div>I like that how that reads.</div><div><br></div><div>#added: wasn't bad - but I could see myself thinking it meant roughly 'was this value already in the collection'?  Which misses the add part and is backwards on the result (true if present, false if added).</div><div><br></div><div>-cbc</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
><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| seen added: each]<br>
><br>
> messagesDo: aBlock<br>
>       "Evaluate aBlock exactly once with all the message selectors sent by me."<br>
><br>
>       | scanner aSet |<br>
>       self isQuick ifTrue: [ ^self ].<br>
>       scanner := InstructionStream on: self.<br>
>       scanner scanFor: [ :x |<br>
>               | selector |<br>
>               (selector := scanner selectorToSendOrSelf) == scanner ifFalse: [<br>
>                       ((aSet ifNil: [ aSet := IdentitySet new ]) added: selector) ifTrue: [<br>
>                               aBlock value: selector ] ].<br>
>               false "keep scanning" ]<br>
><br>
><br>
><br>
> > On Jun 15, 2017 12:19 PM, "Eliot Miranda" <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br>
> > Hi Tobias,<br>
> ><br>
> > On Thu, Jun 15, 2017 at 12:06 PM, Tobias Pape <<a href="mailto:Das.Linux@gmx.de">Das.Linux@gmx.de</a>> wrote:<br>
> ><br>
> > > On 15.06.2017, at 20:30, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">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">leves@caesar.elte.hu</a>> wrote:<br>
> > > On Wed, 14 Jun 2017, <a href="mailto:commits@source.squeak.org">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/<wbr>trunk/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-<wbr>10d50c0dae29<br>
> > > Ancestors: Collections-eem.755<br>
> > ><br>
> > > Add SequenceableCollection>><wbr>withoutDuplicates for a more elegant fix to MailMessage>>to:<br>
> > ><br>
> > > =============== Diff against Collections-eem.755 ===============<br>
> > ><br>
> > > Item was added:<br>
> > > + ----- Method: SequenceableCollection>><wbr>withoutDuplicates (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>
> > Well, we do have<br>
> ><br>
> >         Collection>>addIfNotPresent:<br>
> ><br>
> > So why invent a new one?<br>
> ><br>
> > Because addIfNotPresent: answers its argument and we need one that answers whether the element was absent.  So alas addIfNotPresent: is not a suitable candidate.<br>
> ><br>
> ><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>
> ><br>
> > 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.<br>
> ><br>
> > Stéphane, can you live with ifMissingAdd: ?  Chris?<br>
> ><br>
> > Best regards<br>
> >         -Tobias<br>
> ><br>
> > > _,,,^..^,,,_<br>
> > > best, Eliot<br>
> ><br>
> > _,,,^..^,,,_<br>
> > best, Eliot<br>
><br>
> _,,,^..^,,,_<br>
> best, Eliot<br>
><br>
<br>
<br>
</div></div></blockquote></div><br></div></div>