lua-users home
lua-l archive

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


Hi Thomas,

Shows again that one should always post all versions in use when posting a problem ;-)

I will keep this in mind!

Thank you very much!
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 19:38 GMT+09:00 Thomas Jericke <tjericke@indel.ch>:
Hi Journeyer
Well actually, I was just assuming that you are using Lua 5.2, because we switched long ago.

Shows again that one should always post all versions in use when posting a problem ;-)
--
Thomas

Hi Thomas Jericke,

I should have told you that the account.lua uses the function module().
And using this module() function places a global variable. And removing this variable fixes this problem.

Thank you for the concern.

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 16:13 GMT+09:00 Thomas Jericke <tjericke@indel.ch>:
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



-- 
Indel AG
Thomas Jericke - Management
Tuefiwis 26
CH-8332 Russikon
Switzerland

Tel.: +41 44 956 20 00
www.indel.ch

---------------------------------------------------------------------
iDev replaces IMD as the official IDE for Indel embedded programming.
http://www.indel.ch/en/news/149-idevnews