[erlang-questions] module_info and code switch

Fred Youhanaie fly@REDACTED
Wed Nov 27 10:07:44 CET 2013

On 26/11/13 21:02, Andreas Stenius wrote:
> 2013/11/26 Fred Youhanaie <fly@REDACTED>
>> [...]
>> Curiously I noticed that as soon as I load a new version of the module,
>> module_info/1 returns the attribute of the currently loaded version rather
>> than the version for the running process!
>> Is this intentional?
> Yes.
> I see that you call the local `module_info/1` function, but the
> implementation of that in your module is simply to forward the call to
> `erlang:get_module_info/2`, so it doesn't matter if you call it on your old
> or new version of the code, it will give the same result in both cases.
> Which will be that of the active version of the module, according to [1].
> Cheers.
> [1]
> https://github.com/erlang/otp/blob/maint/erts/emulator/beam/beam_load.c#L5251


Thanks for the explanation.

So, this means that "-Vsn" is not reliable for identifying (introspection) the version of the code executing a function :-(


More information about the erlang-questions mailing list