lua-users home
lua-l archive

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


> Yes, I understand perfectly. However, according to the documentation
> for "require"
> (http://www.lua.org/manual/5.1/manual.html#pdf-require),
> after calling require ("foo") while the "foo" file begins with
> "module(bar)", the value of package.loaded["foo"] ("foo", not "bar"!)
> should be set to true, which it isn't. It's nil!

Here is what I get :
-- foo.lua
module("bar", package.seeall)
print("loading ".._NAME.." as "..(...))
-- test.lua --> the output
local tmp = require 'foo' --> loading bar as foo
print(tmp) --> true
print(package.loaded.foo) --> true
print(package.loaded.bar) --> table: 00336EC0

So if you don't get that your installation has a problem. Are you using
Lua 5.0 with compat-5.1 ?

Oh, now we are getting to the heart of the problem. The above is what
I expected and I wasn't getting it. Specifically, I was getting "nil"
instead of "true" at the "print (tmp)" line.

You know what the problem was? I was inputting the lines at the Lua
command prompt and thus "local tmp = ... " was different variable than
the one in "print (tmp)". Oops... Sorry all...

--
Frantisek Fuka (yes, that IS my real name)
(and it's pronounced "Fran-tjee-shek Foo-kah")
My E-Mail: fuka@fuxoft.cz
My Homepage: http://www.fuxoft.cz
My blog: http://blog.fuxoft.cz
My Jabber/GoogleTalk ID: fuxoft@gmail.com