A different semantics for WeakMap#get default value
François REMY
fremycompany_pub at yahoo.fr
Tue Jan 17 04:00:28 PST 2012
If I just can add my own two cents about the naming convention :
get(key)
get(key, valueIfMissing)
set(key, newValue)
getOrSet(key, newValueIfMissing)
// kinda like openOrCreate on most file systems
François
-----Message d'origine-----
From: Herby Vojčík
Sent: Tuesday, January 17, 2012 12:45 PM
To: Brendan Eich
Cc: Mark S. Miller ; es-discuss
Subject: Re: A different semantics for WeakMap#get default value
Brendan Eich wrote:
> Clearly(!) a set-if-not-present method should not be misnamed "get".
>
> I like the optional sentinel-meaning-not-found for get, and setDefault
> per Python as Tab pointed out. Agree they should not be merged into one
> API. Bikeshedding setDefault at leisure (in background in my head ;-).
Like:
getIfAbsentSet(key, dflt)
with dflt being mandatory?
Still there is question of laziness of dflt, the original
#get:ifAbsentPut: has the block as its second argument.
>
> /be
> _______________________________________________
> 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
More information about the es-discuss
mailing list