lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


There are also problems when using dll library that has been linked with static crt, or a different version of the CRT.

It happens quite a lot with plugins for example.

On 5/16/2012 11:57 AM, Francesco Abbate wrote:
2012/5/16 Gé Weijers<ge@weijers.org>:
I usually delay setting the metatable until the object is in a defined
state, which is hard to do with this idiom. If the constructor of the object
throws a C++ exception and you catch it the "__gc" routine  the metatable
refers to may call the destructor, which is a bad idea because the
constructor failed.

I've banned C++ exceptions from gsl shell, the application I'm
currently developing. The reason is that they pose a serious
integration problem, I'm using a C++ library that is itself not
exception safe. In addition I think that C++ exceptions and Lua
setjmp/longjmp are pretty much incompatibles. To be honest the
setjmp/longjmp is also unfriendly to normal C++ stack unwinding but
exceptions just complicate the scenario even more.

If you add, in addition exceptions that can be thrown from
constructors and destructors you may end up with a big headache :-)

No exceptions and your life is simpler. This is the KISS principle I guess :-)

Francesco