don't enable strict or warnings with 'use Moose 3;' #186
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: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 beforeimport
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.