[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Re-requiring modules
- From: Elias Barrionovo <elias.tandel@...>
- Date: Tue, 22 Oct 2013 13:53:23 -0200
If you remove it's entry from package.loaded, and require it, it will
be loaded again.
But it's no so simple, because of possible side effects, locals,
upvalues and the like. Example:
local mod = require 'mymodule'
local foo = mod.foo
local mod = re_require 'mymodule'
print(foo == mod.foo) -- what now?
On Tue, Oct 22, 2013 at 1:45 PM, Justin Cormack
<justin@specialbusservice.com> wrote:
>
> On 22 Oct 2013 16:38, "Robert Virding" <robert.virding@erlang-solutions.com>
> wrote:
>>
>> Is it possible to re-require a module? The documentation implies that it
>> is not possible as if the module has been loaded then it will be remembered
>> in the package.loaded table and the next time is it loaded then this value
>> will be reused.
>>
>> The scenario I was thinking about is a long-lived application where you
>> need to upgrade a module but don't want to take down the system as you will
>> have a lot state which needs to be maintained.
>>
>> It would also be interesting to speculate how to handle multiple versions
>> of a module in the same system. In one sense it would be easy if they were
>> kept in different places but overwriting an existing one may be tricky.
>>
>
> Sure, you can change package.loaded or just write your own require. The
> difficult bits are on the application side but all the tools are there.
>
> Justin
--
NI!
() - www.asciiribbon.org
/\ - ascii ribbon campaign against html e-mail and proprietary attachments