lua-users home
lua-l archive

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


> Perhaps it would useful to explain what the compiler does. As I
> understand it a file or string  gets translated and evaluated to the
> equivalent of:
> 
> (function(_ENV)
>   return function(...)
>     <<< your file/string content here >>>
>   end
> end)( <<< current environment >>> )
> 
> and any unbound variable 'x' in the file gets rewritten to _ENV["x"]
> (or equivalently _ENV.x)
> 
> Assigning to _ENV is just that, assigning to a variable.
> 
> And unless I'm completely barking up the wrong tree that's all the
> magic there is.

You are barking the right tree ;)

Just to clarify: <<< current environment >>> there should mean the
global environment, unless you use "loadin".

-- Roberto