An often seen recommendation on best practices regarding Moose
is the following:
"The use
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, includingMoose
keywords. Once the class has been built, these keywords are not needed. (This is preferred to placingno Moose
at the end of your package)."
Taken for Moose::Manual::BestPractices (emphasis mine).
I understand everything regarding the quote above, except for one thing: why is the use of namespace::autoclean
preferred to the use of no Moose
at the end of the lexical scope?
Is it just because namespace::autoclean
is more versatile, allowing for more options in its use, or is there something intrinsic to the way it was implemented (specially tailored for Moose
classes, perhaps) that makes it more reliable?
I found no documentation clarifying this, and I would much like to know the right answer.
namespace::autoclean
will also break your code if you're planning on using overloads at the same time. For that case you may want to try outnamespace::sweep
. – Photoconduction