On 2 September 2014 15:19, Brendan Eich <[email protected]> wrote: > > Indeed we do not want post-mortem resurrection, but any id would have the problem too, if it were strongly linked; and would have a similar problem if weak.
Would it? If the object is freed before the trap, then the trap just gets some sort of object id. Then it can call out to the external resource manager: "hey, resource id 123 isn't needed any more". Which could then free it. > In terms of LuaVM, can you say very concretely what you need? A handle to the LuaVM peer of the proxy, the object the proxy reflects into JS? Currently in Lua.vm.js when a Lua object is exposed to Javascript, we place it in the registry (an associative array), under an unused integer key. This integer key is placed inside of a Javascript object. This object then has methods '.get()' '.set()' '.invoke()', etc. When one of these methods is called, it uses the integer id to look the object up in the lua registry, then performs the selected operation on that looked up value. For the implementation, check out: https://github.com/kripken/lua.vm.js/blob/6a3b8fb99b84017de61f763e2541389d4d14577b/src/lua.js#L527 I'm hoping that in future, this can be re-written to use Javascript Proxys, this way, you don't need `ob.get(foo)` but can index the Proxy directly: `ob[foo]`. > GC is quite involved, and as you suggest, not to be exposed naively to JS "user code". > > Have you seen > > http://wiki.ecmascript.org/doku.php?id=strawman:weak_references > > which has evolved on es-discuss: > > http://esdiscuss.org/topic/what-is-the-status-of-weak-references > http://esdiscuss.org/topic/es6-es7-es8-and-beyond-a-proposed-roadmap > > and probably other threads I'm forgetting. Yeah I have, you could implement post-mortem finalizers by polling a WeakValue Map, though I don't think that's the best course of action. I thought narrowing the scope to just Proxy objects might be a bit more palatable. The discussions around security issues are somewhat interesting, though I think allayed by my proposal of an undefined interval (i.e. possibly delayed, or random) between the reference being dropped, and the finaliser getting called.
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

