Skip Menu |
 
rt.cpan.org will be shut down on March 1st, 2021.

This queue is for tickets about the future CPAN distribution.

Report information
The Basics
Id: 92525
Status: resolved
Priority: 0/
Queue: future

People
Owner: Nobody in particular
Requestors: TEAM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: 0.26



Subject: ->export_to_level in Future::Utils
Download (untitled) / with headers
text/plain 703b
Currently Future::Utils is just importing the 'import' sub from Exporter - for some helper modules it's useful to apply imports to the caller, particularly for tidying up the 'use' list when similar patterns of modules are used in several places. Something along the lines of: use Some::Helper::Module qw(:all); try { fmap_void { pairmap { } ... } } catch { ... }; Inheriting from Exporter is my usual approach for this, alternatively would it be possible to add export_to_level to the import list? With the inheritance approach, there seems to be a bug with base.pm (https://github.com/doy/try-tiny/pull/11) which parent.pm doesn't have (https://github.com/doy/try-tiny/issues/14). cheers, Tom
Download (untitled) / with headers
text/plain 398b
On Mon Jan 27 22:02:32 2014, TEAM wrote: Show quoted text
> Inheriting from Exporter is my usual approach for this, alternatively > would it be possible to add export_to_level to the import list?
I've occasionally run into odd issues by inheriting from Exporter; I prefer the explicit import approach. Does importing 'export_to_level' as well fix it? If so I'll go adding that to the import list. -- Paul Evans
Download (untitled) / with headers
text/plain 776b
On Wed Feb 05 13:34:14 2014, PEVANS wrote: Show quoted text
> Does importing 'export_to_level' as well fix it? If so I'll go adding > that to the import list.
Hmm. At first glance it would seem not: $ bzr di === modified file 'lib/Future/Utils.pm' --- lib/Future/Utils.pm 2014-02-22 03:50:03 +0000 +++ lib/Future/Utils.pm 2014-03-25 16:56:50 +0000 @@ -10,7 +10,7 @@ our $VERSION = '0.25'; -use Exporter 'import'; +use Exporter qw( import export_to_level ); our @EXPORT_OK = qw( call $ perl -Mblib -MFuture::Utils -E 'BEGIN { Future::Utils->export_to_level(0); } repeat { foo };' Can't locate object method "export_to_level" via package "Future::Utils" at -e line 1. BEGIN failed--compilation aborted at -e line 1. Odd that it still managed to import it though. -- Paul Evans
Download (untitled) / with headers
text/plain 667b
On Tue Mar 25 12:57:48 2014, PEVANS wrote: Show quoted text
> On Wed Feb 05 13:34:14 2014, PEVANS wrote:
> > Does importing 'export_to_level' as well fix it? If so I'll go adding > > that to the import list.
> > Hmm. At first glance it would seem not:
Turns out that Exporter specialcases importing itself, and ignores any other symbol names. Also, manually importing &Exporter::export_to_level doesn't work as it fails due to inheritance: Can't locate object method "export" via package "Future::Utils" at /usr/share/perl/5.18/Exporter/Heavy.pm line 200. Turns out though that implementing export_to_level is a trivial wrapper around ->import. See attached patch -- Paul Evans
Subject: rt92525.patch
Download rt92525.patch
text/x-diff 425b
=== modified file 'lib/Future/Utils.pm' --- lib/Future/Utils.pm 2014-02-22 03:50:03 +0000 +++ lib/Future/Utils.pm 2014-03-25 17:20:22 +0000 @@ -11,6 +11,11 @@ our $VERSION = '0.25'; use Exporter 'import'; +# Can't import the one from Exporter as it relies on package inheritance +sub export_to_level +{ + my $pkg = shift; local $Exporter::ExportLevel = 1 + shift; $pkg->import(@_); +} our @EXPORT_OK = qw( call
Released in 0.26 -- Paul Evans


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

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.