lua-users home
lua-l archive

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

Roberto Ierusalimschy <> writes:
>> Also, if you are deprecating setfenv, then it probably makes sense
>> to add an optional second parameter to the load routines which would
>> provide the environment to associate with the loaded chunk [...]
> There is be another function for that, loadin. (Both 'load' and
> 'loadin' accept the chuck both as a function, as in 5.1, or as a
> string.)

I'm not sure if this is really a good replacement for setfenv/getfenv --
looking at my own uses of lua, while my main use of "setfenv" is to set
the environment of a loaded file before evaluating it, the split between
loading the chunk and setting its environment is often quite convenient
and it's useful to be able to reference the current environment (e.g.,
with an "include" function that does getfenv(2), and then makes a new
environment which inherits that when evaulating a loaded chunk).


Yo mama's so fat when she gets on an elevator it HAS to go down.