lua-users home
lua-l archive

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


On 03/06/2014 06:58 AM, Journeyer J. Joh wrote:
Hi,

In PIL (for lua 5.1), there exists a explanation about reloading of a module.

package.loaded["account"] = nil 

This is it. So simple.
I tried to get two different instances from the same module with this method like below.

local aaa = require "account"
print(aaa)
package.loaded["account"] = nil 
local bbb = require "account"
print(bbb)

But the result shows below.

table: 0x1875950
table: 0x1875950

Both aaa and bbb are same. This isn't what I want. I want them to be different.
I guess my wish is impossible.
I guess the reload by the statement below is only *reloading* of the same module.

package.loaded["account"] = nil 

There is no way to make two instances of a module.

Am I right?

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
----------------------------------------
Are you sure that the table isn't just allocated at the same place, after all you don't use local aaa anymore. Maybe you can try

local aaa = require "account"
package.loaded["account"] = nil 
local bbb = require "account"
print(aaa .. ', ' .. bbb)

Just wondering
--
Thomas