Re Proposal: Add Map.prototype.putIfAbsent
andrea.giammarchi at gmail.com
Fri Oct 12 22:12:24 UTC 2018
You slightly missed my point Peter ... put and set are completely different
and it wouldn't be awkward to have them both, neither I'm suggesting to put
in annex b set or put: both have use cases, both are valid, both add
values, both are different.
On Fri, Oct 12, 2018 at 7:43 PM Peter Hoddie <peter at hoddie.net> wrote:
> we have `substr` and `slice` as well that do slightly different things
> with slightly different names and there are valid use cases/simplification
> for both string methods
> substr is in Annex B for web compatibility.
> The specification notes:
> All of the language features and behaviours specified in this annex have
> one or more undesirable characteristics and in the absence of legacy usage
> would be removed from this specification
> These features are not considered part of the core ECMAScript language.
> Programmers should not use or assume the existence of these features and
> behaviours when writing new ECMAScript code. ECMAScript implementations are
> discouraged from implementing these features unless the implementation is
> part of a web browser or is required to run the same legacy
> ECMAScript code that web browsers encounter.
> Our XS engine for emebdded followed this guidance: we didn't implement
> strstr for a long time. Alas, developers from the web are so accustomed to
> having it that we eventually gave in and provided it. Some conformance
> details here:
> -- Peter
> On Oct 12, 2018, at 9:54 AM, Andrea Giammarchi <
> andrea.giammarchi at gmail.com> wrote:
> I think having both `set` and `put` would be actually awesome, we have
> `substr` and `slice` as well that do slightly different things with
> slightly different names and there are valid use cases/simplification for
> both string methods.
> AFAIK Allen mentioned it'd be awkward to have put too, but I hope others
> agree it would solve most issues developers have with constants and one/off
> WeakMap setups which is the most common use case with weak maps, weak sets,
> and not weak counterparts.
> On Fri, Oct 12, 2018 at 3:57 AM Jack Lu <jacklu at jacklu.me> wrote:
>> It makes sense for a `put` to return the value, but it's awkward to say
>> `put` when you want to get a value.
>> And I'm fond of your proposal of `put`.
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss