lua-users home
lua-l archive

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

Is there any danger in exposing setjmp/longjmp outside of the pcall-mechanism in Lua?

I'm investigating creating a try-catch-like system without resorting to closures... Preliminary idea would be something like:

if try() do
abort() -- jumps back to try setting something denoting error

Handle return value optionally rethrowing...

Haven't had much time to think of semantics, but I figured I'd make sure that using stack manipulation like this wouldn't be fatal.
One potential case would be to implement RAII-type features for Lua.

Another item... would it be possible to make the 'pcall'/'error' system work in this way... so that a normal error would be caught in the non-function method?