Weak event listener
Mark S. Miller
erights at google.com
Tue Mar 26 14:56:40 PDT 2013
Because the weak-map-maker constructor grants no privilege and can be
generally accessible, whereas the weak-ref-maker grants the privilege of
being able to observe the non-determinism of GC, and so should not be made
accessible to code that shouldn't have such powers. It is the same reason
why Maps and Sets, which are enumerable, enumerate their elements in a
In short, separation of concerns as well as separation of privileges.
Those who have access to both a weak-map-maker and a weak-ref-maker can
trivially build a non-deterministic enumerable-weak-map-maker if they wish.
In fact, at <
I even show another useful non-deterministic weakish-map-maker
(WeakValueMap) whose utility requires observable non-determinism, and
show how to build it from a weak-map-maker and a weak-ref-maker.
 Either that, or I was not clever enough to build something that could
serve this purpose without exposing non-determinism. If someone is more
clever and does see how to do that, please speak up. Thanks.
On Tue, Mar 26, 2013 at 8:26 PM, Brandon Benvie <bbenvie at mozilla.com> wrote:
> On 3/26/2013 1:03 PM, David Bruant wrote:
>> I'm starting to wonder whether bringing weakrefs is equivalent to having
>> iterable WeakMaps... And if so, why not make WeakMaps iterable?
> This is a question I had as well. An iterable WeakMap is nearly the same
> as a Map full of WeakRefs, is it not? Just a different API that is less
> usable for single references and more usable for collections.
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss