lua-users home
lua-l archive

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


Hi Thijs Schreijer,

Your method works!!

I knew that the module() placed the global variable and this variable was the reason of my problem as you also know.

I was going to remove module(), but your method is simpler!

Thank you very much! This would be 5.1 only problem.

Thank you!
Sincerely
Journeyer


----------------------------------------
Journeyer J. Joh
o o s a p r o g r a m m e r
a t
g m a i l  d o t  c o m
----------------------------------------


2014-03-06 18:45 GMT+09:00 Thijs Schreijer <thijs@thijsschreijer.nl>:
> -----Original Message-----
> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
> Behalf Of Journeyer J. Joh
> Sent: donderdag 6 maart 2014 9:00
> To: Lua mailing list
> Subject: Re: Can I get two instances of the same module?
>
> Hi Peter Melnichenko and Dirk Laurie,
>
> I tested under
>
> Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
>
> And now things seem confusing...
> What I imported by require is from the url below.
> http://lua-users.org/wiki/TemplatePattern
> The account.lua.
>
> And I have no idea then...
>
> Regards
> Journeyer
>

Try this:

local aaa = require "account"
print(aaa)
package.loaded["account"] = nil
local bbb = require "account"
print(bbb)
print(account) --> global was created by module() function

-- try again by also setting global to nil
account = nil
package.loaded["account"] = nil
local ccc = require "account"
print(ccc)
print(account)

the above works for me.
Thijs