Mark Miller (2013-11-07T03:04:35.000Z)
The handler gets notified by the garbage collector. There are two
conventional ways for this to be specific to the object being gc'ed.

1) Just create a unique handler for each weakref registration. If *this*
handler gets notified, then it knows that the object it was about has been
gc'ed.

2) (The old Smalltalk way) Have the primitive abstraction be a vector of
weakrefs, which for short I'll just call a weak vector. (I avoid the term
"array" here only because we're talking about JavaScript.) Handlers are
registered on a weak vector as a whole, not on individual indexes. The
handler notification message includes the index of the cauterized (nulled)
reference.

The WeakRef proposal I wrote up uses technique #1. Technique #2 has
implementation advantages and we should consider it.




On Wed, Nov 6, 2013 at 3:14 PM, Rick Waldron <waldron.rick at gmail.com> wrote:

>
>
>
> On Wed, Nov 6, 2013 at 2:15 PM, Domenic Denicola <
> domenic at domenicdenicola.com> wrote:
>
>> Thanks Mark for the education, especially on the pre- vs. post-morterm
>> finalization distinction. I don't think I was specifically advocating for
>> pre-mortem in my OP, since I didn't really understand the difference :P.
>> Post-mortem finalization sounds quite reasonable. What do people think of
>> introducing it into ECMAScript?
>>
>
> This may be a naïve question, but how would the handler know which
> object/weakref had been gc'ed?
>
> Rick
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
Text by me above is hereby placed in the public domain

  Cheers,
  --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20131106/013eb2ed/attachment-0001.html>
domenic at domenicdenicola.com (2013-11-17T17:49:05.901Z)
The handler gets notified by the garbage collector. There are two
conventional ways for this to be specific to the object being gc'ed.

1. Just create a unique handler for each weakref registration. If *this*
handler gets notified, then it knows that the object it was about has been
gc'ed.

2. (The old Smalltalk way) Have the primitive abstraction be a vector of
weakrefs, which for short I'll just call a weak vector. (I avoid the term
"array" here only because we're talking about JavaScript.) Handlers are
registered on a weak vector as a whole, not on individual indexes. The
handler notification message includes the index of the cauterized (nulled)
reference.

The WeakRef proposal I wrote up uses technique #1. Technique #2 has
implementation advantages and we should consider it.