在Erlang中,如何从模块导入所有函数? [英] In Erlang how can I import all functions from a module?

查看:364
本文介绍了在Erlang中,如何从模块导入所有函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何导入模块的所有功能,而无需指定各个功能。

I can't figure out how to import all the functions of a module without having to specify the individual functions.

推荐答案

正如Christian所说:不可能从模块导入所有功能。编译器没有 import_all 指令,我认为这是故意的,以阻止过多的功能导入。

As Christian says, "It is not possible to import all functions from a module." The compiler has no import_all directive and I think this is done deliberately to discourage excessive function importing.

导入功能完全符合他们 M:F(...)通常是不好的风格。调用模块本地函数和另一个模块中的函数(代码加载规则)之间存在语义上的差异,所以我认为最好让外部调用显式。可能会导入dict / lists / sets模块函数的异常,因为这些通常被理解,并且在代码升级期间不太可能发生变化。

Importing functions instead of fully qualifying them M:F(...) is usually bad style. There is a semantic difference between calling a module-local function and a function in another module (code-loading rules), so I think it's best to make foreign calls explicit. One could possibly make exceptions for importing dict/lists/sets module functions, as those are commonly understood and are unlikely to change during a code upgrade.

这篇关于在Erlang中,如何从模块导入所有函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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