On your question about namespace::sweep:
Firstly, take note of the actual problem that namespace::sweep resolves.
In particular, namespace::autoclean will remove special symbols that are installed by overload, so you can't use namespace::autoclean on objects that overload Perl operators.
What this means is that if your class has overloaded operators they won't work if you also use namespace::autoclean
. But this problem only occurs if you use overload
. Other than that, namespace::autoclean will suffice.
Secondly, it says that namespace::sweep can be used instead of namespace::autoclean:
In most cases, namespace::sweep should work as a drop-in replacement for namespace::autoclean. Upon release, this pragma passes all of namespace::autoclean's tests, in addition to its own.
So to answer your question, "is it correct to use namespace::sweep or I should use namespace::autoclean or none of them?"
- You should use at least one of them as recommended by Moose Best Practices.
- It is generally ok to use namespace::sweep since it says it is designed to do so and it passes all of namespace::autoclean's tests.
- In spite of point 2 above, if you don't
use overload
then you don't have a problem with using namespace::autoclean, so you could just use that in this case.