On Thu Dec 08 19:27:30 2011, jeff@imaginative-software.com wrote:
Show quoted text>
> On Dec 8, 2011, at 4:16 PM, Tom Wyant via RT wrote:
>
> > And the above was found in the throes of adding another
> configuration
> > option, 'allow_perl_version', to allow the aforementioned 'use
> 5.010;'
> > before the package statement. This was committed as SVN revision
> 4100.
>
>
> Does it make sense to have that as a separate option from
> allow_import_of? Would we gain anything by permitting this in the
> config:
>
> [Modules::RequireExplicitPackage]
> allow_import_of = 5.10 utf8 strict
>
> -Jeff
Well, to me it made sense for two reasons:
First, 'use 5.010;' seems to me different semantically than 'use Foo;'.
The first form specifies a version of Perl, the second loads a module.
ExtUtils::MakeMaker considers them different, specifying modules via
PREREQ_PM, and the minimum Perl with MIN_PERL_VERSION. Module::Build
considers them less different, but looks at 'use 5.010;' as being more
like requiring version 5.010 of pseudo-module 'perl'. So my read is that
the Module::Build approach would be more like
[Modules::RequireExplicitPackage]
allow_import_of = perl utf8 strict
Second, because though they are both represented by a
PPI::Statement::Include, if the PPI object represents a 'use 5.010;' the
module() method returns false and the version() method returns 5.010,
whereas for 'use Foo;' the module() method returns 'Foo' and the
version() method returns false. So the two constructions take separate
paths through the code anyway. Unless I ignore Adam's take on the
situation as well, and just use $elem->schild( 1 ) to retrieve the
module/version.
Honestly, though, the real reason for not just doing
allow_import_of = 5.10
is that it just feels weird and fragile to me. Weird, because that
syntax disallows 'use 5.x;' for any 'x' but that explicitly listed.
Fragile because it the minimal implementation treats 'use 5.010;', 'use
5.10.0;', 'use v5.10;' as being different. The principal of least
surprise says they ought all to be equivalent.
Plus, it seems to me if we're really interested in restricting the
version of Perl specified by 'use 5.x;', it should be a policy all on
its own.
Anyhow, that's my take. But I made this a separate commit so that it
could be removed if it seemed on discussion to be a bad idea.