lua-users home
lua-l archive

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


Hello,

first of all I want to say it is a very interesting patch. Very usefull.

I guess you can publish your project over the LuaForge (http://luaforge.net/) web site. It is a lua web site for this kind of patchs, projects, etc.
Or if you prefer just attach the content in a email to the mail list.

Congratulations by the patch.

Lucas de Oliveira Teixeira

On Jan 29, 2008 1:19 AM, Hu Qiwei <huqiwei@gmail.com> wrote:
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