david.bruant at labri.fr
Wed Sep 14 13:24:48 PDT 2011
I have come across use cases where i didn't need a Weak/Map/, but rather
a Weak/Set/ which is that I didn't need to set a value. Usually, i set
"true" but feel like I'm doing something useless. The API I actually
* .add(obj) (add an element to the set which is one in WeakMaps with .set)
Even if i haven't had the need for it, a .has(obj) method would be
relevant as well for WeakSets.
Also, I would like to talk a little bit about terminology. WeakMaps have
their name inspired by the idea of "weak" references which have
particular garbage-collection properties. From the developer
perspective, this seems to be some sort of implementation detail they
should not be aware of.
As far as I know, current functions/constructors have their name
inspired by the contract they fulfill rather than implementation
considerations. The difference between current WeakMaps and Maps is
their contract. In the latter, keys can be enumerated, in the former
not. I think that this is the difference that should inspire different
names rather than the implementation optimisation that is induced by
this contract difference.
More information about the es-discuss