Proxy objects and collection
quae at daurnimator.com
Tue Sep 2 13:16:19 PDT 2014
On 2 September 2014 15:19, Brendan Eich <brendan at mozilla.org> 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 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?
we place it in the registry (an associative array), under an unused integer
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:
this way, you don't need `ob.get(foo)` but can index the Proxy directly:
> GC is quite involved, and as you suggest, not to be exposed naively to JS
> Have you seen
> which has evolved on es-discuss:
> 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
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss