allen at wirfs-brock.com
Wed Sep 14 23:09:31 PDT 2011
On Sep 14, 2011, at 9:42 PM, Kyle Simpson wrote:
> I too have been confused by the name "weakmap"...partially because the name is misleading, and partially because documentation on it is ambiguous/misleading. Specifically, "weakmap" really means "weakkeymap", because only the key is weak, not the value. But then again, "weakkeymap" would be even more implementation-instead-of-semantics naming.
We've discussed the naming of this abstraction several times:
https://mail.mozilla.org/pipermail/es-discuss/2010-July/011465.html resulted in WeakMap name
and at least two of the above threads seem to have their start in confusion over the meaning of "weak" in this context.
I continue to think that "WeakMap" is a poor name (although it is much better than "EphemerionMap", which it replaced). To me, "weak" in this context is not a meaningful term for everyday programmers. It is GC jargon. It also adds nothing to a user's conceptual model of the abstraction. If a "map" is a non-enumerable associative table, then you would never want to have a nonweakMap as that would simply be a leaky map, i.e a buggy map implementation. Perhaps it can be argued is that, in the case of WeakMap, the "Weak" really is intended to mean nonleaky/nonbuggy and that this is necessary to make this explicit because of the prevalence of leaky map implementations in other languages.
I would prefer ObjectMap (the keys are restricted to objects). ObjectRegistry is another possibility that is suggestive of a primary use cases. Kyle's suggestion of Map would also be fine although I think there is a valid objection that the name is too general (and perhaps too conflict prone) given that the keys may not be values other than objects.
This issue keeps coming back around, starting with different people. Perhaps the present name really is a problem and we could revisit it. Is not, my guess is that we will see the same issue again.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss