Skip Menu |
Report information
Id: 131142
Status: pending release
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: kencotterill [at] netspace.net.au
Cc:
AdminCc:

Operating System: (no value)
PatchStatus: (no value)
Severity: low
Type: unknown
Perl Version: (no value)
Fixed In: (no value)



To: perlbug - RT for Perl <perlbug [...] perl.org>
Subject: "if" pragma POD addition for modules with an empty import list
From: Ken Cotterill <kencotterill [...] netspace.net.au>
Date: Thu, 13 Apr 2017 13:18:18 +1000
Download (untitled) / with headers
text/plain 900b
This relates to if.pm (version: 0.0606). The current documentation refers to loading modules with or without ARGUMENTS (i.e. for import()). It doesn't mention using an empty import list which is not possible with the current implementation. This patch adds a few lines to the POD to explain this; it also suggests a workaround. --- if.pm 2017-04-12 08:26:15.000000000 +1000 +++ if-new.pm 2017-04-12 09:31:05.000000000 +1000 @@ -50,6 +50,15 @@ If you don't use the fat comma (eg you don't have any ARGUMENTS), then you'll need to quote the MODULE. +If you wanted ARGUMENTS to be an empty list, i.e. have the effect of: + + use MODULE (); + +you can't do this with the C<if> pragma; however, you can achieve +exactly this effect, at compile time, with: + + BEGIN { require MODULE if CONDITION } + =head2 EXAMPLES The following line is taken from the testsuite for L<File::Map>:
RT-Send-CC: perl5-porters [...] perl.org
On Wed, 12 Apr 2017 20:21:58 -0700, kencotterill@netspace.net.au wrote: Show quoted text
> This relates to if.pm (version: 0.0606). > > The current documentation refers to loading modules > with or without ARGUMENTS (i.e. for import()). > > It doesn't mention using an empty import list > which is not possible with the current implementation. > > This patch adds a few lines to the POD to > explain this; it also suggests a workaround.
Thanks, I'll look into this for 5.27 Show quoted text
> > --- if.pm 2017-04-12 08:26:15.000000000 +1000 > +++ if-new.pm 2017-04-12 09:31:05.000000000 +1000 > @@ -50,6 +50,15 @@ > If you don't use the fat comma (eg you don't have any ARGUMENTS), > then you'll need to quote the MODULE. > > +If you wanted ARGUMENTS to be an empty list, i.e. have the effect of: > + > + use MODULE (); > + > +you can't do this with the C<if> pragma; however, you can achieve > +exactly this effect, at compile time, with: > + > + BEGIN { require MODULE if CONDITION } > + > =head2 EXAMPLES > > The following line is taken from the testsuite for L<File::Map>:
-- Karl Williamson
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 670b
On Thu, 11 May 2017 15:25:50 GMT, khw wrote: Show quoted text
> On Wed, 12 Apr 2017 20:21:58 -0700, kencotterill@netspace.net.au wrote:
> > This relates to if.pm (version: 0.0606). > > > > The current documentation refers to loading modules > > with or without ARGUMENTS (i.e. for import()). > > > > It doesn't mention using an empty import list > > which is not possible with the current implementation. > > > > This patch adds a few lines to the POD to > > explain this; it also suggests a workaround.
> > Thanks, I'll look into this for 5.27 >
Karl, would you like to move forward with the discussion of this request? Thank you very much. -- James E Keenan (jkeenan@cpan.org)
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 169b
Thanks, applied as 16279618f4fddf32c6336e8b43059c0392284359 It makes it easier on us if you attach the patch to the ticket, instead of inlining it. -- Karl Williamson


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org