A different semantics for WeakMap#get default value

Mark S. Miller erights at google.com
Thu Jan 19 09:11:55 PST 2012


On Thu, Jan 19, 2012 at 12:00 AM, Andrea Giammarchi <
andrea.giammarchi at gmail.com> wrote:

> On Thu, Jan 19, 2012 at 7:51 AM, Mark S. Miller <erights at google.com>wrote:
>
>>
>> Everyone on this thread, is there any need expressed in this thread that
>> is not satisfied by InfiniteMap?
>>
>>
>
> I would say for "notification purpose"
>
> result = lazyFactory(key, defaultValue);
>
> would be more appropriate
>

Hi Andrea, as I just mentioned in my reply to Andreas, I think this is a
good suggestion. However,




> otherwise the defaultValue looses completely its meaning the moment "key"
> is not there due the first if.
>

That's not quite true in the collection I posted, since an InfiniteMap is
only *initially* total. It still emulates deletes by using tombstones to
poke holes into its initially universal domain. When doing a get at a
deleted key, the defaultValue would come into effect.



>
> Out of curiosity, Chrome experimental flag does not support get(key,
> defaultValue) but get(key) only ... is this something missing or Map and
> WeakMap will never support officially the second get() argument?
>
> br
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120119/ceed7c96/attachment.html>


More information about the es-discuss mailing list