[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: (not) handling new programming idioms with grace
- From: Dibyendu Majumdar <mobile@...>
- Date: Mon, 16 Jul 2018 19:13:15 +0100
On 16 July 2018 at 18:54, Roberto Ierusalimschy <email@example.com> wrote:
>> I don't believe it is technically possible to implement deterministic
>> cleanup of objects in Lua. I think the main issue is Lua's approach of
>> throwing exceptions using longjmp. As far as I know, you need
>> systematic stack unwinding in order to implement something like this -
>> and that would be impossible to do while keeping Lua's primary design
>> criteria - to be small and portable.
>> If you have a technical solution that works - or if anyone else has -
>> would be happy to be corrected.
> We do. All this has been discussed some time ago; see .
> (BTW, you brought the same issue to that thread, and you got the
> answer there :-)
Indeed this was discussed before - I thought then and now the problem
is that deterministic cleanup is difficult when errors are thrown. I
do not recall seeing a solution to that - I re-read your replies just
now, and the solution did not stand out to me.
> However, a main issue of any "deterministic cleanup" in Lua is its
> interaction with coroutines. A coroutine can enter a block and never
> leave it.
I am not sure that this is a problem ... at least if we are talking
about the same thing.
In languages where you have a 'finally' block - the block only
triggers if the stack unwinds through it. If you start some other
thread and that thread never returns back to the same stack then the
finally would never run.