加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

如果我要在Perl中使用纯OO,我是否需要Exporter?

发布时间:2020-12-16 06:23:58 所属栏目:大数据 来源:网络整理
导读:文档(Exporter和perlmodlib)说: As a general rule,if the module is trying to be object oriented then export nothing. 但是perlmodlib也说: Standard,bundled modules are all expected to behave in a well-defined manner with respect to namespace
文档(Exporter和perlmodlib)说:

As a general rule,if the module is
trying to be object oriented then
export nothing.

但是perlmodlib也说:

Standard,bundled modules are all
expected to behave in a well-defined
manner with respect to namespace
pollution because they use the
Exporter module.

所以我想知道,如果你去OO并且没有出口,你真的需要出口商吗?如果你不这样做,这是否意味着在这个意义上没有一个标准模块是严格的OO,或者它是否意味着他们EXPORT_OK一些东西,因为你需要这样做,如果有人想从你的模块继承? (这是真的吗?)或者您是否需要Exporter才能使用MyModule; … =新的MyModule?

解决方法

你是对的.如果一切都将被称为OBJECT :: sub()或$obj-> sub(),你应该没问题.

对于继承,您将要使用@ISA,为此,您不需要导出器.

此外,您提供的第二个引用是关于导出到模块中的导出数据.

如果你使用:use libname();对于使用Exporter导出的lib,您可以保证不导出任何内容.这就是它如何用于防止命名空间污染.如果您按功能名称显式导出,那么这些是您获得的唯一功能.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读