我已经完成了一个位于“./local/lib/parser.erl”中的模块“parser”。是否可以从“./local/main.erl”导入模块?
我试图在我的主模块中使用:
-import("./lib/parser", [函数])。
-import('./lib/parser', [函数])。
-import(lib.parser,[函数])。
他们都没有给我正确的编译。我在 Erlang 的文档中进行了搜索,但找不到我要查找的内容。
感谢您的回答。
最佳答案
-import(Module,Functions). Imported functions. Can be called the same way as local functions, that is, without any module prefix.
Module, an atom, specifies which module to import functions from. Functions is a list similar as for export.
你的 erlang 源文件在
./local/lib/parser.erl
,但是编译这个源文件后,会有一个beam
文件,您应该添加 beam
您的 erlang code path
的文件路径.正确的语法是
-import('parser', [functions]).
但是parse.beam
的路径应该在您的 erlang 代码路径中。关于
erlang code path
,请阅读此链接:http://erlang.org/doc/man/code.html
关于import - Erlang 从其他目录导入模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35590740/