Skip Menu |

This queue is for tickets about the Perl6-Export-Attrs CPAN distribution.

Report information
The Basics
Id: 19600
Status: open
Priority: 0/
Queue: Perl6-Export-Attrs

People
Owner: Nobody in particular
Requestors: Smylers [...] stripey.com
Cc:
AdminCc:

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



Subject: IMPORT Block Arguments Containing Export Specifications
Date: Tue, 30 May 2006 16:07:55 +0100
To: bug-perl6-export-attrs [...] rt.cpan.org
From: Smylers <Smylers [...] stripey.com>
Hi there. Thanks for Perl6::Export::Attrs; it seems to be just what I'm looking for. However, I'm finding this bit of functionality doesn't seem to be there: The IMPORT block is passed the argument list that was specified on the use line that loaded the corresponding module. However, any export specifications (names of subroutines or tagsets to be exported) will have already been removed from that argument list before IMPORT receives it. My IMPORT blocks are getting all the arguments, even those which've already been processed. Here's an example module: package ExportTest; use Perl6::Export::Attrs; sub IMPORT { print "IMPORT block with these args [@_].\n" } sub hello :Export { print "Hello\n" } 1; Loading that module yields: $ perl -MExportTest=hello,extra -we 1 This is the custom IMPORT block, with these args [hello extra]. Whereas I'd've expected "hello" to've been stripped and only for "extra" to've made it to the output. Also, I had to put "sub" before "IMPORT" to get the module to compile -- but that was easy to sort out, so it's bothering me much less! Cheers. Smylers
Subject: Re: [rt.cpan.org #19600] IMPORT Block Arguments Containing Export Specifications
Date: Wed, 31 May 2006 08:08:17 +1000
To: bug-Perl6-Export-Attrs [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Show quoted text
> However, I'm finding this bit of functionality doesn't seem to be there: > > The IMPORT block is passed the argument list that was specified on the > use line that loaded the corresponding module. However, any export > specifications (names of subroutines or tagsets to be exported) will > have already been removed from that argument list before IMPORT > receives it. > > My IMPORT blocks are getting all the arguments, even those which've > already been processed.
Yup. It was a bug. Corrected in the latest beta (attached). Show quoted text
> Also, I had to put "sub" before "IMPORT" to get the module to compile -- > but that was easy to sort out, so it's bothering me much less!
Try putting a semicolon after the closing } of the block, like so: IMPORT { print "IMPORT got: @_\n"; }; Perl only allows new types of blocks to be imperfectly simulated. :-( I've updated the docs to cover this point explicitly. Thanks for the report! Damian

Message body is not shown because it is too large.

Subject: Re: [rt.cpan.org #19600] IMPORT Block Arguments Containing Export Specifications
Date: Wed, 31 May 2006 11:47:36 +0100
To: "damian [...] conway.org via RT" <bug-Perl6-Export-Attrs [...] rt.cpan.org>
From: Smylers <Smylers [...] stripey.com>
damian@conway.org via RT writes: Show quoted text
> > My IMPORT blocks are getting all the arguments, even those which've > > already been processed.
> > Yup. It was a bug. Corrected in the latest beta (attached).
Thanks; that's very helpful of you.. Though I note that now we have that functionality, we no longer have the docs describing it: it's been removed from both the comments in the synopsis and the 'IMPORT blocks' subsection. Also, the pattern for testing whether an import request could be a subroutine name has been changed from: if (my ($sub_name) = $request =~ m/\A &? ($IDENT) (?:\(\))? \z/xms) { to this: if (my ($sub_name) = $request =~ m/\A & ($IDENT) (?:\(\))? \z/xms) { Which forces module users to write things like: use Some::Module qw<&foo &bar>; rather than the more usual: use Some::Module qw<foo bar>; Could we possibly have that question mark back in there? Show quoted text
> > Also, I had to put "sub" before "IMPORT" to get the module to > > compile -- but that was easy to sort out, so it's bothering me much > > less!
> > Try putting a semicolon after the closing } of the block, like so: > > IMPORT { > print "IMPORT got: @_\n"; > };
That didn't work with the released version, but it does work with the beta you supplied. But again the docs now seem to reflect the old functionality: the synposis says "sub IMPORT" and now calls it a subroutine rather than a block -- and with the new functionality it's now an error to write it as "sub IMPORT". Best wishes. Smylers
Subject: Re: [rt.cpan.org #19600] IMPORT Block Arguments Containing Export Specifications
Date: Thu, 01 Jun 2006 08:35:09 +1000
To: bug-Perl6-Export-Attrs [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Further modifications to this module are on hold whilst the design team nut out the actual interface that IMPORT handlers will have. It now seems likely that IMPORT will be a subroutine (*not* a block) with a full signature that will be applied to any 'use' or 'require' that loads it. It might not be called IMPORT either, since it doesn't import anything from its own point-of-view. I also envisage being able to decide whether or not IMPORT (or whatever it's called) sees the arguments that were used to trigger "is export" behaviour. I'd prefer the next release of P::E::A to track Perl 6's mechanism as closely as possible, so I'm not going to release it until I have a clearer idea what that mechanism will look like. Thanks for your patience, Damian