lua-users home
lua-l archive

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


On 16 April 2013 08:59, Philipp Janda <siffiejoe@gmx.net> wrote:
> at the top of the file anyway, and some people have written setfenv[1][2][3]
> for Lua 5.2 and I feared that one of those functions could end up in the
> global environment, or -- even worse -- that someone wrote a completely
> unrelated function with that name, since the name setfenv is fair game now
> in Lua 5.2.

It's no more fair game now than it was before: nothing stops anyone
from redefining any globals. (They're not protected like keywords, of
course.)

That's why what I always wanted from the module system, instead of the
wild-west of package.seeall, was a way to get a guaranteed "reset"
environment (like a 'package.seebase' of sorts) with only the standard
Lua globals. If Lua can construct a default environment for the main
chunk and populate the standard libraries there, I figure it could
just as well do the same for modules, to ensure that module authors
can work with a stable set of assumptions about the environment, just
like script writers do.

-- Hisham
http://hisham.hm/