In my last question @Borodin commented my question with:
You should start by removing Modern::Perl and namespace::sweep. Modules that behave as pragma should be avoided.
I'm confused a bit, because:
- in the LATEST Moose BestPractices manual recommending to use
namespace::autoclean
.
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, including Moose keywords. Once the class has been built, these keywords are not needed. (This is preferred to placing no Moose at the end of your package).
In the Book Intermediate perl
recommending to use the namespace::autoclean
too.
Yes, I'm used the instead of the autoclean
the sweep
module - because again from the doccu
This pragma was written to address some problems with the excellent namespace::autoclean. 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.
... ...
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.
And because I'm an perl beginner, i'm really confused. For me, when i reading: this module addressing some problems of another module - mean: use this one.
'Manual (where from I should learn) says "use it" and expert from stackoverflow teling: don't use it.
So please, can someone explain me:
- it is correct to use
namespace::sweep
or I should usenamespace::autoclean
or none of them? - if none, why the BestPractices recommends it?
For the `ModernPerl'. Sure, I'm probably don't understand deeply and "exactly" what is does. What i know, (again from it's doccu)
This enables the strict and warnings pragmas, as well as all of the features available in Perl 5.10. It also enables C3 method resolution order as documented in perldoc mro and loads IO::File and IO::Handle so that you may call methods on filehandles. In the future, it may include additional core modules and pragmas.
Sure, don't deeply understand to mro
, only think it is an answer to the "deadly diamond of death" problem in cases of multiple inheritance.
Up to today, i was really happy with it, because it is shorting for me the needed pragmas:
use strict;
use warnings;
use feature 'say';
So, what is a "status" of the "Modern::Perl" (and other similar cpanm modules)? Allowed to use, or not?
On your question about namespace::sweep:
Firstly, take note of the actual problem that namespace::sweep resolves.
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 youuse overload
. Other than that, namespace::autoclean will suffice.Secondly, it says that namespace::sweep can be used instead of namespace::autoclean:
So to answer your question, "is it correct to use namespace::sweep or I should use namespace::autoclean or none of them?"
use overload
then you don't have a problem with using namespace::autoclean, so you could just use that in this case.Specifying
use 5.014;
(or other version >= 5.011) will automatically douse strict;
and enable all features of that version for you; IMO this is some of the reason Modern::Perl has not gained a whole lot of traction.I've always disliked
Modern::Perl
because it doesn't describe what it does; it is someone else's idea of "modern" as of some fixed point in the past.