[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Idea for 5.2 : merging _ENV and ... (was: Re: reinstating "in env do ... end")
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 18 Aug 2010 09:22:22 -0300
> 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