开发者

Erlang/OTP: Changes to the already existing modules

I am working over soluti开发者_StackOverflow中文版on to a problem, which requires changes in one of the functions of module gb_trees.

I am getting an error compiling the edited version of gb_trees:

1> c(gb_trees).
cannot write to .bea#
...
2>

What's the way I can make changes and compile an already existing module?


Probably your file is being used by another process. Close all applications, that you're using or restart your OS, then try to recompile.

You're trying to manually load a module , which is a part of Erlang/OTP.

From documentation:

The Erlang runtime system is protecting you.

The easiest solution is to rename your module, e.g. to mysets.erl. It is also possible to 'un-stick' the directory containing the library module.

See code:unstick/1.

Also:

To prevent accidentally reloading modules affecting the Erlang runtime system itself, the kernel, stdlib and compiler directories are considered sticky. This means that the system issues a warning and rejects the request if a user tries to reload a module residing in any of them. The feature can be disabled by using the command line flag -nostick.

See erl(1).

For example:

$ erl -nostick
Eshell V5.7.3  (abort with ^G)
1> c(gb_trees).
{ok,gb_trees}
2> gb_trees:module_info().
[{exports,[{foo,2},{module_info,0},{module_info,1}]},
 {imports,[]},
 {attributes,[{vsn,[338095567601101424197378397768992511838]}]},
 {compile,[{options,[]},
           {version,"4.6.3"},
           {time,{2011,2,3,11,39,53}},
           {source,"/tmp/gb_trees.erl"}]}]
3>

You see that we can compile and load the module into VM.

However you could just rename your module gb_trees to something like gb_trees_mine and use functions it exports:

1> gb_trees_mine:foo(13,42).
bar
2>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜