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

MooseX::POE also provides strict and warnings #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

simbabque
Copy link

This is part of my entry for the Pull Request Challenge in 2017 towards the dist semifor/twirc. This commit fixes a Kwalitee issue in one of the modules inside that dist, which is in fact not an issue at all.

@charsbar
Copy link

Thanks for the PR. I understand your point but I have not yet decided if this should be merged, because MooseX::POE doesn't explicitly explain in the pod that it loads strict and warnings into caller's namespace, and the code is not so obvious about that.

@simbabque
Copy link
Author

simbabque commented Aug 15, 2017

I felt the same way. What I did to check was actually try it out with the SYNOPSIS of MooseX::POE.

$ cat test.pl

package Counter;
use MooseX::POE;

has count => (
    isa     => 'Int',
    is      => 'rw',
    lazy    => 1,
    default => sub { 0 },
);

sub START {
    my ($self) = @_;
    $self->yield('increment');
}

event increment => sub {
    my ($self) = @_;
    print "Count is now " . $self->count . "\n";
    $self->count( $self->count + 1 );
    $self->yield('increment') unless $self->count > 3;
};

no MooseX::POE;

Counter->new();
POE::Kernel->run();

I then run this through B::Deparse.

$ perl -MO=Deparse test.pl
package Counter;
sub BEGIN {
    require MooseX::POE;
    do {
        'MooseX::POE'->import
    };
}
use warnings;
use strict;
has('count', ('isa', 'Int', 'is', 'rw', 'lazy', 1, 'default', sub {
    0;
}
));
sub START {
    my($self) = @_;
    $self->yield('increment');
}
event('increment', sub {
    my($self) = @_;
    print 'Count is now ' . $self->count . "\n";
    $self->count($self->count + 1);
    $self->yield('increment') unless $self->count > 3;
}
);
no MooseX::POE;
'Counter'->new;
'POE::Kernel'->run;
test.pl syntax OK

As you can see, there's a use strict and use warnings there, so I assumed that was imported via Moose.

Removing one of the my keywords from that code will result in errors, which is another indicator that strict is on.

I tested that on 5.20.1. Let me see if I have an older one laying around.

@karenetheridge
Copy link

karenetheridge commented Aug 15, 2017

strict and warnings are coming from this line in MooseX::POE:

my ( $import, $unimport, $init_meta ) = Moose::Exporter->setup_import_methods(
    with_caller     => [qw(event)],
    also            => 'Moose',        # <-- this line
    ...

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.

3 participants