What is the status of Weak References?

Brandon Benvie brandon at brandonbenvie.com
Fri Feb 1 07:18:13 PST 2013


And by fail I mean result in a set of objects that next gets collected by
the GC correctly despite being otherwise fit to be collected.


On Fri, Feb 1, 2013 at 10:12 AM, Brandon Benvie
<brandon at brandonbenvie.com>wrote:

> Indeed, and Continuum uses the same strategy for implementing WeakMap
> currently. To my knowledge, the circumstances that makes that
> implementation of WeakMap fail is unlikely to arise except in the case of a
> membrane. As a polyfill provided to developers devloping with ES5 as a
> target, this is acceptable since a membrane requires an implementation of
> Proxy. But since Continuum implements Proxy, this sets up the one case
> where the two (lack of native WeakMaps and Proxy) to meet.
>
>
> On Fri, Feb 1, 2013 at 10:07 AM, David Bruant <bruant.d at gmail.com> wrote:
>
>> Le 01/02/2013 15:53, Brandon Benvie a écrit :
>>
>>  It's not possible to polyfill or emulate weak references (or WeakMaps
>>> for that matter) in JS without completely disengaging from using the host
>>> JS engine's object model.
>>>
>> For all practical purposes, you've done such a thing yourself
>> https://github.com/Benvie/**WeakMap <https://github.com/Benvie/WeakMap>;-)
>>
>>
>>  In Continuum, for example, I can get close but not quite all the way to
>>> emulating WeakMaps using a meta-interpretive approach to the object model
>>> (each object in the VM corresponds to one or more objects in the host
>>> engine). Eventually I'll switch to switching to using my own
>>> typedarray-backed heap with a GC in order to fully realize the semantics of
>>> WeakMaps.
>>>
>> There are probably minor limitations to your above implementation, but I
>> wonder if they're worth the trouble to move to a typedarray heap. It's your
>> call not mine anyway :-)
>>
>> David
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130201/e4750154/attachment.html>


More information about the es-discuss mailing list