[squeak-dev] The Trunk: Collections-eem.756.mcz

Eliot Miranda eliot.miranda at gmail.com
Thu Jun 15 18:30:01 UTC 2017


Hi Levente, Hi Chris,

On Wed, Jun 14, 2017 at 1:10 PM, Levente Uzonyi <leves at caesar.elte.hu>
wrote:

> On Wed, 14 Jun 2017, commits at source.squeak.org wrote:
>
> Eliot Miranda uploaded a new version of Collections to project The Trunk:
>> http://source.squeak.org/trunk/Collections-eem.756.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Collections-eem.756
>> Author: eem
>> Time: 14 June 2017, 11:03:24.917631 am
>> UUID: 8d7c03bc-1cdb-44c7-9173-10d50c0dae29
>> Ancestors: Collections-eem.755
>>
>> Add SequenceableCollection>>withoutDuplicates for a more elegant fix to
>> MailMessage>>to:
>>
>> =============== Diff against Collections-eem.755 ===============
>>
>> Item was added:
>> + ----- Method: SequenceableCollection>>withoutDuplicates (in category
>> 'copying') -----
>> + withoutDuplicates
>> +       "Answer a copy of the receiver that preserves order but
>> eliminates any duplicates."
>> +       | seen |
>> +       seen := Set new: self size.
>> +       ^self select: [:each|
>> +                                 (seen includes: each)
>> +                                       ifTrue: [false]
>> +                                       ifFalse: [seen add: each. true]]!
>>
>
> What a great opportunity to use #addNewElement::
>
>         ^self select: [ :each | seen addNewElement: each ]


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: ?

Here are some suggestions.  Votes?
- don't change it; stick with addNewElement:
- addIfAbsent:
- ifAbsentAdd:
- ifMissingAdd:

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.


> Levente
>

_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170615/4578e8b7/attachment.html>


More information about the Squeak-dev mailing list