import - Erlang 从其他目录导入模块

标签 import module erlang

我已经完成了一个位于“./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/

相关文章:

android - 如何通过链接(而不是复制)使应用程序使用其自身文件夹之外的模块?

python - 在 python 启动时自动加载模块

mongodb - ChicagoBoss 似乎没有将正确的值保存到 MongoDB 中

erlang - Erlang 是集群计算世界的 C 语言吗?

Python:导入的 Tkinter 程序自行运行?

reactjs - 为什么需要在父子组件中多次导入React?

c++ - [C++] 导入文本文件 - getline() 的问题

php - 为普通 header 导入 html 文件无法读取 <head> 和相关的 javascript 和 css 源

javascript - 如何在我的 Angular 4.x 项目中使用 js 库作为模块?

erlang - Elixir 紧循环加速