[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Can I get two instances of the same module?
- From: Peter Melnichenko <petjamelnik@...>
- Date: Thu, 06 Mar 2014 11:46:19 +0400
> local aaa = require "account"
> print(aaa)
> package.loaded["account"] = nil
> local bbb = require "account"
> print(bbb)
Generally this must work, meaning that aaa and bbb must be different instances of the module. It may not work in your particular case if the module requires submodules, they must all be reloaded.
For example, consider luasocket:
```lua
-- socket.lua
local socket = require("socket.core")
local _M = socket
...
return _M
```
Here the table of the module actually comes from the "socket.core" module, so if you want to get a completely new instance it should be reloaded, too(and other socket.* modules).