perl – 为什么“使用namespace :: autoclean”优先于“no Moose”?

前端之家收集整理的这篇文章主要介绍了perl – 为什么“使用namespace :: autoclean”优先于“no Moose”?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
关于Moose的最佳做法的经常看到的建议如下:

“The use @H_404_4@namespace::autoclean bit is simply good code hygiene,as it removes imported symbols from your class’s namespace at the end of your package’s compile cycle,including @H_404_4@Moose keywords. Once the class has been built,these keywords are not needed. (This is preferred to placing @H_404_4@no Moose at the end of your package).”

Moose::Manual::BestPractices(重点为我).

我理解上述引用的一切,除了一件事情:为什么使用namespace :: autoclean比较适合在词法范围的末尾使用Moose?

它只是因为namespace :: autoclean是更多功能,允许更多的选择在其使用,或者有什么内在的方式实现(特别为Moose课程量身定做,这可以使它更可靠?

我发现没有文件澄清这一点,我很想知道正确的答案.

解决方法

没有麋鹿只摆脱通过使用Moose导入的功能.使用namespace :: autoclean可以摆脱所有导入的函数.

如果你总是使用namespace :: autoclean,那么如果你稍后回来并从某个模块导入一个函数,那么你不需要记住不要使用Moose来使用namespace :: autoclean.否则,你可能会忘记这样做.

猜你在找的Perl相关文章