简体   繁体   English

erlang模块的模块信息中未更新MD5

[英]MD5 is not getting updated in Module info of erlang module

FYI: I just started to learn Erlang with the help of https://learnyousomeerlang.com . 仅供参考:我刚刚在https://learnyousomeerlang.com的帮助下开始学习Erlang。

While going through the chapters I encountered about module_info. 在浏览各章时,我遇到了有关module_info的内容。 The following is the output that I got for one of the module. 以下是我为该模块之一获得的输出。

[{module,useless},
 {exports,[{add,2},
           {hello,0},
           {greet_and_add_two,1},
           {module_info,0},
           {module_info,1}]},
 {attributes,[{vsn,[296174539721071843666185210011547328263]},
              {author,"An Erlang Champ"}]},
 {compile,[{version,"7.4"},
           {options,[debug_info,export_all]},
           {source,"/Users/vivekdhayalan/useless.erl"}]},
 {native,false},
 {md5,<<222,209,36,56,31,223,59,231,71,237,66,109,149,39,
        223,7>>}]

I have noticed md5 attribute in my output on curious I updated my module and checked the module info after compiling by module once again. 我好奇地在输出中注意到了md5属性,我更新了模块并在再次由模块编译后检查了模块信息。 But, I still found the same md5 thinking what could be the reason. 但是,我仍然发现相同的md5,这可能是什么原因。

If you have any clues please help to understand. 如果您有任何线索,请帮助理解。 Might, be I'm to curious about md5 as I'm yet complete the chapter. 可能是因为我对MD5感到好奇,因为我尚未完成本章。

note: vsn is also not getting updated 注意:vsn也没有更新

Updating with more info. 更新更多信息。

My initial code: 我的初始代码:

-module(useless).
-export([add/2, hello/0, greet_and_add_two/1]).

add(C,B) ->
C + B.

%% Shows greetings.
%% io:format/1 is the standard function used to output text.
hello() ->
io:format("Hello, world!~n").

greet_and_add_two(X) ->
hello(),
add(X,2).

Module info & compile steps 模块信息和编译步骤

28> compile:file(useless, [debug_info, export_all]).
{ok,useless}
29> useless:module_info().                          
[{module,useless},
 {exports,[{add,2},
           {hello,0},
           {greet_and_add_two,1},
           {module_info,0},
           {module_info,1}]},
 {attributes,[{vsn,[296174539721071843666185210011547328263]},
              {author,"An Erlang Champ"}]},
 {compile,[{version,"7.4"},
           {options,[debug_info,export_all]},
           {source,"/Users/vivekdhayalan/useless.erl"}]},
 {native,false},
 {md5,<<222,209,36,56,31,223,59,231,71,237,66,109,149,39,
        223,7>>}]

I'm updating my module just with adding author as below 我只是通过添加作者来更新我的模块,如下所示

-module(useless).
-export([add/2, hello/0, greet_and_add_two/1]).
-author("An Erlang Champ").

add(C,B) ->
C + B.

%% Shows greetings.
%% io:format/1 is the standard function used to output text.
hello() ->
io:format("Hello, world!~n").

greet_and_add_two(X) ->
hello(),
add(X,2).

my module info after compile. 编译后我的模块信息。

compile:file(useless, [debug_info, export_all]).
{ok,useless}
31> useless:module_info().                          
[{module,useless},
 {exports,[{add,2},
           {hello,0},
           {greet_and_add_two,1},
           {module_info,0},
           {module_info,1}]},
 {attributes,[{vsn,[296174539721071843666185210011547328263]},
              {author,"An Erlang Champ"}]},
 {compile,[{version,"7.4"},
           {options,[debug_info,export_all]},
           {source,"/Users/vivekdhayalan/useless.erl"}]},
 {native,false},
 {md5,<<222,209,36,56,31,223,59,231,71,237,66,109,149,39,
        223,7>>}]

As we could see the md5 has not updated even after adding info. 如我们所见,即使添加了信息, md5也没有更新。

compile:file() compiles to a new .beam file on disk, but does not load it. compile:file()编译为磁盘上的新.beam文件,但不会加载该文件。 The module_info() function reports the status of the loaded version. module_info()函数报告已加载版本的状态。 The shell c() shortcut will both compile and load - use that instead for interactive work. shell c()快捷方式将同时进行编译和加载-将其用于交互式工作。

-module(my).
-compile([export_all]).

go() -> "hello".

In the shell: 在外壳中:

~/erlang_programs$ erl
Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V9.3  (abort with ^G)

1> c(my).
my.erl:2: Warning: export_all flag enabled - all functions will be exported
{ok,my}

2> my:module_info().
[{module,my},
 {exports,[{go,0},{module_info,0},{module_info,1}]},
 {attributes,[{vsn,[317460282063015155415500557234702055363]}]},
 {compile,[{options,[]},
           {version,"7.1.5"},
           {source,"/Users/7stud/erlang_programs/my.erl"}]},
 {native,false},
 {md5,<<"îÔ W­ÝÒ\n©¥ëíQ&÷Ã">>}]

Adding another function: 添加另一个功能:

-module(my).
-compile([export_all]).

stop() -> "goodbye".
go() -> "hello".

In the shell: 在外壳中:

5> c(my).           
my.erl:2: Warning: export_all flag enabled - all functions will be exported
{ok,my}

6> my:module_info().
[{module,my},
 {exports,[{stop,0},
           {go,0},
           {module_info,0},
           {module_info,1}]},
 {attributes,[{vsn,[210928589040636765166954307796272702313]}]},
 {compile,[{options,[]},
           {version,"7.1.5"},
           {source,"/Users/7stud/erlang_programs/my.erl"}]},
 {native,false}, 
 {md5,<<158,175,94,91,0,91,194,106,194,244,45,224,190,48,
        99,105>>}]

I updated my module and checked the module info after compiling by module once again. 在再次按模块编译后,我更新了模块并检查了模块信息。 But, I still found the same md5 thinking what could be the reason. 但是,我仍然发现相同的md5,这可能是什么原因。

Prove it. 证明给我看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM