lua-users home
lua-l archive

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


> However, "import" loads module.lua using an empty environment, one that
does
> not even contain _ERRORMESSAGE, and so no message is reported.
> Try
> local newenv = {_ERRORMESSAGE=_ERRORMESSAGE}
>
> The code you used for "import" was based on some code posted to the list
> as an example. For production, you have to be careful when you use
"globals",
> because almost everything "vanishes".
> --lhf

Yes this is far from "production". I only started experimenting with
Roberto's code as a starting point last night and then I noticed this. Your
explanation makes sense, but leaves me confused about why the getglobal tag
method that import sets lets the code executed with dofile see global
functions like print and globals from the file that called import, but not
_ERRORMESSAGE.