[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: goto jumps into scope of local (Lua 5.2.0-beta)
- From: Miles Bader <miles@...>
- Date: Sun, 03 Jul 2011 10:00:04 +0900
David Manura <dm.lua@math2.org> writes:
> Secondly, and more importantly, the gotos will be rejected as written
> because they jump into the scope of locals [*2] ....
I think people will cope OK...
There are several obvious ways to do so --
(1) in the presence of gotos, pre-declare any variables necessary to
avoid "jumping into a scope":
   local x
   ...
   if err_cond then goto ::cleanup_return::
   ...
   x = something()
   ...
   return x
   ::cleanup_return::
   cleanup()
   return nil
(2) use nested scopes to limit the scope of new variables:
   ...
   if err_cond then goto ::cleanup_return::
   ...
   do
      local x = something()
      ...
      return x
   end
   ::cleanup_return::
   cleanup()
   return nil
-miles
-- 
Non-combatant, n. A dead Quaker.