[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Behaviour of "local"
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 22 Feb 2001 14:43:37 -0300 (EST)
>When you run test.lua with module written this way, the function report
>isn't printed.
The problem is that module.lua gives a parse error:
$ lua module.lua
error: cannot access a variable in outer scope;
last token read: `modname' at line 7 in file `module.lua'
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