[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Why is the stack cleared on panic?
- From: "Thomas Harning Jr." <harningt@...>
- Date: Mon, 10 Jan 2011 15:47:16 -0500
On Mon, Jan 10, 2011 at 11:51 AM, Alexander Gladysh <firstname.lastname@example.org> wrote:
> On Mon, Jan 10, 2011 at 19:37, Julio Merino <email@example.com> wrote:
>> On Mon, Jan 10, 2011 at 4:29 PM, Alexander Gladysh <firstname.lastname@example.org> wrote:
>>> On Mon, Jan 10, 2011 at 18:50, Julio Merino <email@example.com> wrote:
>>> Um. This looks like you intend to work from C++ with Lua, compiled as C.
>>> In general, this is not a good idea.
>> Yep, I found that the hard way. That said I'd prefer the ability to
>> use prebuilt Lua libraries shipped as binary packages (for your
>> preferred distro). Is that a bad idea in general too? (Maybe yes
>> based on the amount of settings in luaconf.h... but I'm very new
>> around here!)
> No, that is not a bad idea, if your use case allow it, this is the
> best way to do it.
> OTOH, C++ and Lua, compiled in plain C, really do not play well together.
> You may try to use LuaJIT 2, it is ABI-compatible with most of plain C
> modules (at least ones who play by the rules), and (I have an
> impression that) it covers C/C++ error handling, if built correctly. I
> did not check it myself though.
Lua does indeed play well with C and C++ at the same time... no need
to specially compile Lua as C++.
Now, you do need to make sure that you protect your call-sites Lua->C
so that C++ exceptions don't bubble past Lua as well as Lua errors
don't bubble past C++ stack mgmt (always pcall).
Thomas Harning Jr.