[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: 2nd version: try..catch for Lua, now "finally" supported
- From: Polarina <gabrielp@...>
- Date: Wed, 30 Jan 2008 21:20:48 +0000
And even if we threw the error after we have set x to the number 3, it
would still print "nil" since x would be out of scope when we call
print.
On Wed, 2008-01-30 at 11:40 -0800, Mark Hamburg wrote:
> on 1/30/08 10:48 AM, Fabien at fleutot+lua@gmail.com wrote:
>
> > Incidentally, by writing this example, I'm thinking that maybe the
> > catch-blocks and the finally-block should share the same scope as the
> > try-block (i.e. if local h was declared after the "try" above, it would still
> > be accessible to the "finally" code. Just as the "until" condition in plain
> > Lua's "repeat...until" is in the loop body's scope). I'm interested by
> > potential users advices, before maybe putting that in metalua 0.4.
>
> Horrendous flow control problems in that case:
>
> try
> error( "Throw" )
> local x = 3
> catch err do
> print( x )
> end
>
> At the point where we threw the error, x did not exist.
>
> Mark
>
>