简体   繁体   English

Erlang:模块属性

[英]Erlang: module attribute

I am new to Erlang. 我是Erlang的新手。 Found the following -module attribute declaration in an existing Erlang project: 在现有的Erlang项目中找到以下-module属性声明:

-module(mod_name, [Name, Path, Version]).

What does mean the second parameter (list [Name, Path, Version]) here? 这里的第二个参数(列表[名称,路径,版本])是什么意思?

I haven't found any information in the Erlang reference on it. 我没有在Erlang参考文献中找到任何信息。

This defines a parameterised erlang module - one you can "instantiate" with new and then access the parameters passed by that new when executing code in your module. 这定义了一个参数化的erlang模块 - 你可以用new实例化一个,然后在你的模块中执行代码时访问新的传递的参数。

A very brief overview is here: 这里有一个非常简短的概述:

http://myotherpants.com/2009/04/parameterized-modules-in-erlang/ http://myotherpants.com/2009/04/parameterized-modules-in-erlang/

This is a parametrized module. 这是一个参数化模块。 Here is the original paper on it. 这是关于它的原始论文 Basically you can create instances of the module binding specific values to those variables. 基本上,您可以创建模块的实例,将特定值绑定到这些变量。 You can initialize one as: 您可以将其初始化为:

> Mod = mod_name:new("MyName", "/path", '0.1').

and then call its functions as: 然后将其函数称为:

> Mod:function(...)

where the module parameters are also available in the function body. 其中模块参数也可在函数体中使用。

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

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