Mark Miller (2013-11-07T03:04:35.000Z)
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.