Proxy objects and collection
jason.orendorff at gmail.com
Thu Sep 4 05:42:54 PDT 2014
On Tue, Sep 2, 2014 at 1:07 PM, Daurnimator <quae at daurnimator.com> wrote:
> I'm the maintainer of lua.vm.js, which allows Lua code to run in the
> I've managed to construct a simple and robust cross-language bridge, so that
> collector notifies me (via the __gc metamethod).
> At this point, I drop the reference to the JS object, and the JS garbage
> collector can collect it if needed.
> have the same ability;
> your object.
> Example use case:
> A Lua script wishes to have a Lua function called on an interval:
> `timerid = window:setInterval(function() window.console:log("ping") end)`
> Later, it wishes to clear the timer:
> This will stop the function from being called, but I have no way to notify
> Lua that the function can be collected.
If the JS function contains the only strong reference to the Lua
function, then when the JS function is collected, the Lua function
will be collected too. Why isn't that sufficient? Does the Lua runtime
keep a list of all functions or something? What for?
More information about the es-discuss