[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Re-requiring modules
- From: Jose Torre-Bueno <jtorrebueno@...>
- Date: Tue, 22 Oct 2013 08:52:01 -0700
On Oct 22, 2013, at 8:37 AM, 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.
>
> Robert
>
I do this routinely with the following function:
function reload(s) package.loaded[s] = nil return require(s) end -- forces a reload of a file, for debuging in interactive interpreter
Jose de la Torre-Bueno, Ph.D.
Empowered Energy Solutions Inc.
Intellectual Property & Technology Management
T (619) 977-0553
F (760) 295-7119
jtorrebueno@cox.net