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
deterministic order.

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[1], and
show how to build it from a weak-map-maker and a weak-ref-maker.

[1] 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
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130326/86bdc3f3/attachment.html>

More information about the es-discuss mailing list