Removal of WeakMap/WeakSet clear

Andrea Giammarchi andrea.giammarchi at gmail.com
Thu Nov 27 08:06:24 PST 2014


Right, the compromise then is usually to use a descriptor with
`enumerable:false` that won't break "the common web" but agreed it's not
that reliable or safe ... although developers are interested in the "weak"
bit, and most of them most likely won't deal with "new" kind of objects
such Proxies and/or frozen/sealed but I understand your point and that's
why I've been happily using an Array for keys and one for values that never
failed, but also never granted weakness requiring either the usage of clear
or delete, which is usually more problematic.

Now I let Mark answer your initial questions and stop talking about
polyfills since there's not a clear winner anyway.

Regards


On Thu, Nov 27, 2014 at 3:17 PM, Andreas Rossberg <rossberg at google.com>
wrote:

> On 27 November 2014 at 15:58, Andrea Giammarchi
> <andrea.giammarchi at gmail.com> wrote:
> > On Thu, Nov 27, 2014 at 2:44 PM, Andreas Rossberg <rossberg at google.com>
> > wrote:
> >> Well, there is no functionally correct polyfill for WeakMaps that is
> >> actually weak, regardless of .clear.
> >
> > Please bear with me so I understand your point: if you have `o1` and `o2`
> > and `o1.link = o2;`, wouldn't `o2` be "free" once `o1` is not referenced
> > anymore ?
>
> Yes, but this approach only works for regular, extensible, writable
> objects o1, i.e., fails for frozen or sealed objects, proxies, etc.
> And of course, as a polyfill for weak maps, it breaks other things,
> such as correctly iterating over properties of an object used as a
> key.
>
> /Andreas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141127/f3ef833a/attachment-0001.html>


More information about the es-discuss mailing list