lua-users home
lua-l archive

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

There is a Lua program that allows users to add their scripts in such a way that them will be callable via the program's menu (or via hot keys).

Every user usually organizes his scripts and modules in a separate subdirectory (subtree, in fact) of the main Lua program, and adds this subdirectory in front of package.path. This is not elegant, but moreover, is not safe, since different users may have identically named modules.

I thought of a solution, where the program assigns each user (that is, each group of scripts) a separate environment and calls those scripts within that environment. But AFAIK, there is no way to have a package.path per an environment, there is only one package.path.

There is one simple solution: the program modifies package.path every time it is about to run a user script. But though it would work, it looks inelegant in comparison to imaginary "package.path per environment".

Are there some other solutions?