Erlang 中的元组模块是什么? [英] What is a tuple module in Erlang?

查看:26
本文介绍了Erlang 中的元组模块是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://www.erlang.org/news/35 提到这将被记录在案,但我可以在文档中找不到它.

http://www.erlang.org/news/35 mentioned that this will be documented, but I can't find it in the documentation.

推荐答案

元组模块"是具有两个元素的元组,模块名称和额外参数列表.例如:

A "tuple module" is a tuple with two elements, the name of a module and a list of extra arguments. For example:

{my_module, [foo, bar]}

在函数调用中可以使用这样的元组代替模块名称.在这种情况下,被调用的函数将获取有问题的元组作为参数列表末尾的附加参数:

Such a tuple can be used instead of a module name in function calls. In this case, the function being called will get the tuple in question as an additional argument at the end of the argument list:

3> Module = {lists, [[foo]]}.
{lists,[[foo]]}
4> Module:append([bar]).
[bar|{lists,[[foo]]}]

这个调用相当于:

7> lists:append([bar], {lists, [[foo]]}).
[bar|{lists,[[foo]]}]

保留元组模块是为了向后兼容,因为它们是参数化模块的实现机制, 已从 R16 中的语言中删除.

Tuple modules are kept for backwards compatibility, as they were the implementation mechanism for parameterised modules, which were removed from the language in R16.

这篇关于Erlang 中的元组模块是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆