[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: block-scope finalization
- From: Coda Highland <chighland@...>
- Date: Tue, 24 Nov 2015 13:18:37 -0800
On Tue, Nov 24, 2015 at 1:16 PM, Dibyendu Majumdar
<mobile@majumdar.org.uk> wrote:
> On 24 November 2015 at 21:10, Coda Highland <chighland@gmail.com> wrote:
>
>> I don't think longjmp is a problem, in and of itself. Microsoft used
>> setjmp/longjmp to implement C++ exception handling and was able to
>> clean up after itself. They switched to a better implementation later,
>> yes, but it's still possible. The important bit, I think, is that
>> setjmp/longjmp isn't part of the exposed Lua API, but instead the Lua
>> internals are able to set up whatever information they need before the
>> longjmp call and between the return to setjmp and the invocation of
>> the panic handler or the resumption of the pcall.
>>
>
> Agreed but I once did a home grown exception handling using longjmp
> and I think the implementation is not at all pretty. Every time a
> 'try' clause is entered, an object needs to be put on the stack linked
> to the previous such object - then there has to be a setjmp within the
> try block. When the code exits the block or an exception is thrown,
> the code needs to longjmp to this setmp, execute any destructors or
> finally code, and then allow normal return. How will all that
> machinary work in lua in the presence of C functions all over the
> place?
Never said it was pretty, but your description sounds about like what
I was expecting.
/s/ Adam
- References:
- Re: block-scope finalization, Viacheslav Usov
- Re: block-scope finalization, Philipp Janda
- Re: block-scope finalization, Viacheslav Usov
- Re: block-scope finalization, Philipp Janda
- Re: block-scope finalization, Philipp Janda
- Re: block-scope finalization, Viacheslav Usov
- Re: block-scope finalization, Coda Highland
- Re: block-scope finalization, Javier Guerra Giraldez
- Re: block-scope finalization, Coda Highland
- Re: block-scope finalization, Patrick Donnelly
- Re: block-scope finalization, Roberto Ierusalimschy
- Re: block-scope finalization, Dibyendu Majumdar
- Re: block-scope finalization, Coda Highland
- Re: block-scope finalization, Dibyendu Majumdar
- Re: block-scope finalization, Coda Highland
- Re: block-scope finalization, Dibyendu Majumdar
- Re: block-scope finalization, Coda Highland
- Re: block-scope finalization, Dibyendu Majumdar