[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Can I get two instances of the same module?
- From: Мельниченко Пётр <petjamelnik@...>
- Date: Thu, 06 Mar 2014 12:26:40 +0400
> 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...
Oh, the good old module.
In both Lua 5.1[1] and Lua 5.2[2] module("foo") tries to use a global variable "foo" as the module table. And it sets it if it can't find it. So, you'll have to either rewrite the module to not use module() or delete global `account` variable before requiring the module the second time.
[1] http://www.lua.org/source/5.1/loadlib.c.html#ll_module ->
/* try global variable (and create one if it does not exist) */
[2] http://www.lua.org/source/5.2/loadlib.c.html#ll_module ->
http://www.lua.org/source/5.2/lauxlib.c.html#luaL_pushmodule ->
/* try global variable (and create one if it does not exist) */