lua-users home
lua-l archive

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


> Roberto Ierusalimschy wrote:
> >If the function collaborates (that is, it has been written to have
> >a variable environment), my preferred idiom is to pass the environment
> >as an argument and to get it in a parameter called _ENV in the function.
> >
> >  function foo (_ENV, a, b, c)
> >    -- code will run in the environment given as first argument
> >    ...
> >  end
> 
> Perfect for all my uses :-)
> Is _ENV inherited by functions called from foo()?

No. It is a perfectly regular variable. But functions *declared* inside
foo will see it (like any other variable).

-- Roberto