lua-users home
lua-l archive

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


Hello,

Now that I'm getting up to speed with Lua, I find the default behavior of assigning everything to the global environment quite disconcerting. It seems to me to be a case of "think locally, act globally". I would much more prefer the reverse: "think globally, act locally".

I'm aware of the setfenv() function, but this require a fair amount of hand holding, is too error prone for my taste as well as fairly obscure all things being equal.

What I would like to setup is something along the following lines:

- By default, things are always 'local' to the file (package) they are declared in. - If I want to export them to the 'global' name space I have to do so explicitly: "global MyGlobalStuff".
- Everything has to be either "local" or "global". No loose ends.

What would be a straightforward way to setup my Lua environment to achieve the above goals?

TIA :)

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/