Hi all,
In larger code bases, we keep getting hit with behavior like this:
$ perl -E 'use Moose; use experimental "signatures"; sub foo($bar)
{$bar + 41}; say foo(1)'
42
$ perl -E 'use experimental "signatures"; use Moose; sub foo($bar)
{$bar + 41}; say foo(1)'
The signatures feature is experimental at -e line 1.
42
In the second example, we get the warning because Moose reloads warnings.
For modules which explicitly disable warnings, it's because we *want *to
explicitly disable those warnings (experimental.pm explicitly unimports
related warnings).
For larger code bases, merely sorting a list of modules you've imported
could cause strange warnings to appear. It can make it very hard to manage,
and in one code base yesterday, we found that strict was somehow being
disabled as a side-effect of similar behavior. This is largely because
those modules are messing with pragmata, changing Perl's compile or run
time behavior, and sometimes those step on each other.
I can think of different ways of dealing with this, but they all seem bad.
My first thought was something like this:
use feature 'signatures';
never warnings 'experimental::signatures'; # lexically scoped, of course
use Moose;
sub foo($bar) { ... }
The above would not generate a warning even though Moose reloads them.
However, you'd still want a way to override never in the current scope. It
would imply a corresponding always keyword: always strict;.
I don't know if this is possible, if it could be generalized, or even if
it's a good idea (I suspect it's not).
Other approaches for dealing with this problem are welcome.
Best,
Ovid
In larger code bases, we keep getting hit with behavior like this:
$ perl -E 'use Moose; use experimental "signatures"; sub foo($bar)
{$bar + 41}; say foo(1)'
42
$ perl -E 'use experimental "signatures"; use Moose; sub foo($bar)
{$bar + 41}; say foo(1)'
The signatures feature is experimental at -e line 1.
42
In the second example, we get the warning because Moose reloads warnings.
For modules which explicitly disable warnings, it's because we *want *to
explicitly disable those warnings (experimental.pm explicitly unimports
related warnings).
For larger code bases, merely sorting a list of modules you've imported
could cause strange warnings to appear. It can make it very hard to manage,
and in one code base yesterday, we found that strict was somehow being
disabled as a side-effect of similar behavior. This is largely because
those modules are messing with pragmata, changing Perl's compile or run
time behavior, and sometimes those step on each other.
I can think of different ways of dealing with this, but they all seem bad.
My first thought was something like this:
use feature 'signatures';
never warnings 'experimental::signatures'; # lexically scoped, of course
use Moose;
sub foo($bar) { ... }
The above would not generate a warning even though Moose reloads them.
However, you'd still want a way to override never in the current scope. It
would imply a corresponding always keyword: always strict;.
I don't know if this is possible, if it could be generalized, or even if
it's a good idea (I suspect it's not).
Other approaches for dealing with this problem are welcome.
Best,
Ovid