Thoughts on WeakMaps

Mike Samuel mikesamuel at gmail.com
Mon Jun 6 14:58:04 PDT 2011


2011/6/6 David Bruant <david.bruant at labri.fr>:
> Le 06/06/2011 17:41, Mike Samuel a écrit :
>> 2011/6/6 David Bruant <david.bruant at labri.fr>:
>>> The consequence of this second point is wondering whether it's a good idea
>>> to standardize WeakMap (instead of Map) at all.
>> Besides a lack of out-of-memory errors and performance, a program
>> using an object key map that doesn't use ephemeron pairs shouldn't
>> behave differently than one that does.  But developers need to have
>> some idea of memory performance when choosing an appropriate
>> collection.  If you're documenting, I would document the behavior
>> around GC upon which devs can rely.
> Not only there is a memory performance difference, but also a key
> enumerability difference. With WeakMaps, keys cannot be enumerated in a
> determinist manner while they can with Map.

Please ignore my last email.  I forgot about Map as a distinct type
and thought you were proposing renaming WeakMap to Map.


More information about the es-discuss mailing list