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 <[email protected]> wrote: > > > > On Wed, Nov 6, 2013 at 2:15 PM, Domenic Denicola < > [email protected]> 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 > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > > -- Text by me above is hereby placed in the public domain Cheers, --MarkM
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

