[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Garbage collection durint pcall.
- From: Dibyendu Majumdar <mobile@...>
- Date: Mon, 3 Jun 2019 19:00:44 +0100
On Mon, 3 Jun 2019 at 18:40, Gé Weijers <ge@weijers.org> wrote:
> On Mon, Jun 3, 2019 at 9:37 AM Francisco Olarte <folarte@peoplecall.com> wrote:
>>
>> I'll just assume finalizers
>>
>> are tainted and avoid them [...]
>
>
> Finalizers can run at any time, and could potentially run in the middle of the execution of any statement, this is true even if Lua had a guarantee that the lifetime of the object extends to the end of the block/scope containing the last reference. They're not "tainted", but you have to guarantee that the finalizer can be run at any possible point in your main program without breaking any of the assumptions (invariants) you make in your code. If the finalizer just closes a file that's no longer needed that is obvious, because it does not reference anything but the object that's 'invisible' to the rest of your program, but if the finalizer changes global state that'll be very difficult if not impossible, because that finalizer may run in the middle of any statement.
>
Hi Francisco,
In general finalizers are frowned upon in languages that have them,
such as for example, in Java, because of the reasons stated above. In
Java therefore the 'finally' clause in a try block is extremely
important for deterministic cleanup. Lua lacked such a feature but
with the proposed 'toclose' feature you might get something that gives
you a bit more control.
Regards
Dibyendu
- References:
- Re: Garbage collection durint pcall., Francisco Olarte
- Re: Garbage collection durint pcall., Gé Weijers
- Re: Garbage collection durint pcall., Philippe Verdy
- Re: Garbage collection durint pcall., Francisco Olarte
- Re: Garbage collection durint pcall., Gé Weijers
- Re: Garbage collection durint pcall., Philippe Verdy
- Re: Garbage collection durint pcall., Francisco Olarte
- Re: Garbage collection durint pcall., Roberto Ierusalimschy
- Re: Garbage collection durint pcall., Roberto Ierusalimschy
- Re: Garbage collection durint pcall., Francisco Olarte
- Re: Garbage collection durint pcall., Roberto Ierusalimschy
- Re: Garbage collection durint pcall., Francisco Olarte
- Re: Garbage collection durint pcall., Gé Weijers