Additional cascading Map/Set/WeakMap methods?

Andrea Giammarchi andrea.giammarchi at gmail.com
Sun Jan 13 20:11:44 PST 2013


+1 since that was my initial (forever dreamed) proposed idea :-)


On Sun, Jan 13, 2013 at 6:53 PM, Brandon Benvie
<brandon at brandonbenvie.com>wrote:

> In that case, it would be really nice for .set to return the value so
> these work:
>
>     return map.has(key) ? map.get(key) : map.set(key, val);
>
> and
>
>     return map.get(key) || map.set(key, val);
>
>
> On Sunday, January 13, 2013, Mark S. Miller wrote:
>
>> My reversal was posted at
>> <https://mail.mozilla.org/pipermail/es-discuss/2012-December/026932.html
>> >.
>> Thanks there to Jussi Kalliokoski for also clearing up this issue.
>>
>> On Sun, Jan 13, 2013 at 6:45 PM, Mark S. Miller <erights at google.com>
>> wrote:
>> > Since then, due to issues pointed out here on es-discuss, I withdrew
>> > my consensus from this decision.
>> >
>> > See also <
>> https://mail.mozilla.org/pipermail/es-discuss/2012-December/026971.html>
>> > where Andreas states the issue more clearly than I did.
>> >
>> >
>> > On Sun, Jan 13, 2013 at 4:44 PM, Allen Wirfs-Brock
>> > <allen at wirfs-brock.com> wrote:
>> >> At the last TC39 meeting, it was agreed tothat the set/add methods
>> would return the collection that to which something is being added.
>> >>
>> >> This supports code patterns like:
>> >>
>> >> someMap.set(key1,value1).set(key2,value3);
>> >>
>> >> In making this change to the spec. I noticed several other methods
>> that could reasonably be used in this same pattern. For example:
>> >>
>> >> someMap.clear().set(aKey, aValue);
>> >>
>> >> someSet.delete(oldMember).add(newMember);
>> >>
>> >> Are there any objections to making the clear and delete methods of
>> Map/WeakMap/Set also return the collection, just like set/add?
>> >>
>> >> Allen
>> >>
>> >>
>> >>
>> >> _______________________________________________
>> >> es-discuss mailing list
>> >> es-discuss at mozilla.org
>> >> https://mail.mozilla.org/listinfo/es-discuss
>> >
>> >
>> >
>> > --
>> >     Cheers,
>> >     --MarkM
>>
>>
>>
>> --
>>     Cheers,
>>     --MarkM
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130113/915e0ad7/attachment-0001.html>


More information about the es-discuss mailing list