lua-users home
lua-l archive

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


steve donovan wrote:
> That is the really interesting question...in Tony's intended
> application, it really is necessary to have some guarantee that the
> hook will be called to restore the environment.

Are you thinking of the hook as a function that takes the environment as
its argument, or would it run 'in' the environment like the code in the
block? If the former:

   in {}, function (t) if t.f then t.f:close() end end do
      f = assert(io.open("script.lua"))
      loadstring(f:read('*all'))()
   end

If the latter:

   in {}, function () if f then f:close() end end do
      f = assert(io.open("script.lua"))
      loadstring(f:read('*all'))()
   end

I prefer the former because it allows you to write the hook outside the
block, and the hook could then be bound to the global environment and
use its services rather than being restricted to the block's environment.

Doug



______________________________________________________________________________________
The information contained in this email transmission may contain proprietary and business 
sensitive information.  If you are not the intended recipient, you are hereby notified that 
any review, dissemination, distribution or duplication of this communication is strictly 
prohibited.  Unauthorized interception of this e-mail is a violation of law.  If you are not 
the intended recipient, please contact the sender by reply email and immediately destroy all 
copies of the original message.

Any technical data and/or information provided with or in this email may be subject to U.S. 
export controls law.  Export, diversion or disclosure contrary to U.S. law is prohibited.  
Such technical data or information is not to be exported from the U.S. or given to any foreign
person in the U.S. without prior written authorization of Elbit Systems of America and the 
appropriate U.S. Government agency.