[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Stack state before running a script
- From: Daurnimator <quae@...>
- Date: Wed, 8 Feb 2017 11:24:48 +1100
On 8 February 2017 at 09:27, chris beck <email@example.com> wrote:
> If JS doesn't have destructors, finalizers, RAII, or any other such built-in
> language feature for the clean up of objects, then I guess you can just add
> explicit "release" methods to your JS representation of a lua object?
> Which would call `luaL_unref`, and tell lua that it is now okay to garbage
> collect that object. I mean presumably this is idiomatic in JS as you also
> will have to call "close" explicitly on file handles and such?
lua.vm.js *does* have this function. but it's essentially unusable.
e.g. if you attach a expose a function as a callback, you generally
have no idea when the DOM will be done with it.
The whole scheme is a dead end.
> Don't have much knowledge of JS myself but I never encountered a problem
> like this before -- I guess it should be workable somehow? JS is a very
> mature technology, and iiuc you'd have the same issue making
> bindings to any other garbage collected programming language.
No it's not fixable.
Weak-refs (https://github.com/tc39/proposal-weakrefs) will get us
However you still have the (unsolvable) problem of cycles across the
two garbage collectors.
The approach taken by Benoit is the *only* good way forward to get lua
working in in web browsers to full effect:
garbage collector can do a full sweep
source=>source transpiler) so that coroutines work correctly.