[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Stack state before running a script
- From: Coda Highland <chighland@...>
- Date: Tue, 7 Feb 2017 14:57:40 -0800
On Tue, Feb 7, 2017 at 2:27 PM, chris beck <beck.ct@gmail.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?
>
> 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.
Idiomatic JS sidesteps the whole mess by not offering any in-language
mechanism for it. If you have a resource that needs finalized, the
host environment needs to take care of that when JS GC's all of the
handles.
/s/ Adam