[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: try..catch in Lua
- From: "alex.mania@..." <alex.mania@...>
- Date: Tue, 29 Jan 2008 13:29:28 +0900
Really looking forward to seeing it in action,
If I understand correctly you can step in to a try without creating/calling any
closures? And so varargs (...) are even valid?
I've never posted a patch, but the page to do so is here:
http://lua-users.org/wiki/LuaPowerPatches
And it looks like the files end up here:
http://lua-users.org/files/wiki_insecure/power_patches/5.1-work6/
I can only assume via ftp, as I have been unable to find any guides.
On Tue Jan 29 11:19 , 'Hu Qiwei' <huqiwei@gmail.com> sent:
>Hi there,
>
>I just wrote a TRY..CATCH extension for Lua, and adapted it into version 5.1.3. The
>syntax is like this:
>
> try
> ... (block) ...
> end
>
>If error occurs in the block, the control immediately jumps to the first
statement after END, and
>the error will be ignored.
>
>another form,
>
> try
> ... (block) ...
> catch err do
> ... (handler) ...
> end
>
>Where err is a variable local to the handler block, which holds the error
object thrown in error(),
>then we can handle the error object in handler block.
>
>Traditional pcall() and xpcall() behavior is intact. You can nest pcall() and
try..catch as you want.
>
>The difference is, you can call coroutine.yield() (or lua_yield in C)
in try..catch block. The implementation
>is platform independent. It uses setjmp...longjmp mechanism so it may not be
quite compatible with
>C++.
>
>I'm new to the mailing list, Could anyone tell me how and where to post the
patch, or just attach
>it in the mail? Thanks.
>
>Hu