[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: what's wrong?
- From: Mike Pall <mikelu-0509@...>
- Date: Sat, 3 Sep 2005 22:22:50 +0200
Hi,
Stukov wrote:
> Please help me to find my mistake in 5.1 alpha compilation.
It's not a problem with your compilation.
> After module(...) all global variables is undefined!
This is documented in the manual that accompanies Lua 5.1 alpha.
Read the comments for package.seeall(), too.
What you really want to do is:
-- Cache any globals you may want to use.
local print = print
local version = _VERSION
-- Load any other modules you may want to use. Example:
-- local foo = require "foo"
-- Start the module definitions. All globals are gone after this!
module(...)
function ccc()
print("Hello world, from ", version, "!\n")
end
Well, unless you were lazy ... then you could just use
module(..., package.seeall)
and continue using globals. But this is slower and not
the recommended practice.
A recent mailing list thread inspired this change:
http://lua-users.org/lists/lua-l/2005-08/msg00429.html
Bye,
Mike