A different semantics for WeakMap#get default value

Herby Vojčík herby at mailbox.sk
Tue Jan 17 03:45:27 PST 2012


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


More information about the es-discuss mailing list