Weak references and destructors
P T Withington
ptw at pobox.com
Sat Dec 12 15:07:18 PST 2009
On 2009-12-11, at 12:43, Brendan Eich wrote:
> It would be more than nice. It is important that the spec not mandate any particular schedule. We have seen endless over-coupling to GC implementation details where programmers who can hook into finalization or another GC phase do so for all the wrong reasons: to close fds, free database cursors, send a message, update UI, etc. Crazy stuff.
In my experience, it is always a bad idea for the GC to invoke user-code.
Please don't throw out the weak-key tables with the finalization bathwater.
> But if there is no guarantee of when the notification might happen, then programmers should not expect any scheduling akin to setTimeout with a timeout of zero.
I initially mis-read this as saying setTimeout with a timeout of 0 might never be scheduled. But that's not what you said.
I was amused by this aside from the strawman:
> Since I can never remember the black/white polarity of traditional gc descriptions, I will use retained for black, fringe for gray, and untraced for white.
More information about the es-discuss