lua-users home
lua-l archive

Re: setfenv/getfenv

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


On Thu, Jan 14, 2010 at 6:49 AM, Nevin Flanagan <Alestane@comcast.net> wrote:
> function catch(valid, ...)
>        if valid then return ...
>        elseif expr1((...)) then
>                handler1
>        elseif expr2((...)) then
>                handler2
>        end
> end
There's a little gotcha if your protected blocks are in a function. Consider
doSomething()
and
doSomething()
return
Both will return nil, but the second clearly wants to return from the
enclosing function; the first does not.
Metalua does try..except, but it's a compiler so it knows if there are
return statements in the block. Tricky to infer it at runtime!
steve d.

AltStyle によって変換されたページ (->オリジナル) /