Moose
Moose copied to clipboard
don't enable strict or warnings with 'use Moose 3;'
I don't think applying strict and warnings via use Moose; is a good feature.
Newer versions of perl enable strict and warnings with a use v5.36; declaration, so it is less useful for Moose to always enable them. It also interferes with experimental features. Attempting to do:
use v5.22;
use warnings;
use experimental qw(signatures);
package Foo;
use Moose;
will result in experimental warnings for signatures still being enabled.
Obviously for compatibility reasons, we can't just stop enabling strict and warnings. But if the user requests a newer version of Moose, we can behave differently. A custom VERSION method can check the requested version before import runs, and control if it enables strict and warnings.
This PR adds a new facility to Moose::Exporter to register a version callback. It will then generate a VERSION method (and possibly install it). Using this callback, Moose, Moose::Role, and Moose::Util::TypeConstriants check if the requested version is >= 3, and if so skip enabling strict and warnings. Skipping is communicated via a hints hash entry.
Any other module using Moose::Exporter will continue to enable strict and warnings unless they use the same facility.
This PR does not yet contain docs or tests. I'll work on that if people like this idea.