lua-users home
lua-l archive

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


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.