Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't enable strict or warnings with 'use Moose 3;' #186

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

haarg
Copy link
Member

@haarg haarg commented Nov 2, 2024

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.

If given a version_callback argument, Moose::Exporter will also produce
(or install) a VERSION method which will perform the core version check
but also call an arbitrary callback.
@haarg haarg marked this pull request as draft November 2, 2024 16:29
lib/Moose/Exporter.pm Outdated Show resolved Hide resolved
Using the version_callback feature, skip enabling strict and warnings if
Moose version 3 is requested. Any other module that uses Moose::Exporter
will continue to enable strict and warnings, as they are outside Moose
and don't follow its versioning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants