develooper Front page | perl.perl5.porters | Postings from February 2003

Re: [PATCH] making Exporter simpler to use

Thread Previous | Thread Next
Fergal Daly
February 14, 2003 10:23
Re: [PATCH] making Exporter simpler to use
Message ID:
On Thursday 13 February 2003 17:54, Tim Bunce wrote:
> Sure. [I think I sounded more harsh than I meant.]
> Modules that only live inside the perl distribution can be
> changed in pretty much any compatible way with new releases.
> But for modules that have a dual life on CPAN I'd be less
> comfortable with adding an extra dependency.

It only lives on CPAN because it has no where else to live at the moment. The 
interface comes from me looking at lots of core modules, seeing how they use 
Exporter and making it easy. I don't see it changing very much if at all as 
there's not that much else one can do with Exporter that isn't covered. I've 
also written scripts to compare the EXPORT_blah variables before and after, 
so that any changes can be checked for disruption.

That said, it doesn't require anything special features of Perl so it should 
be available on CPAN too.

I wasn't suggesting that anything was broken but about 170 core modules use 
Exporter and the same programming maneuvers are shared throughout them. 
This module just encapsulates these maneuvers in one place and also prevents 
other people in the future having reinvent them. I'm not hugely enthusiastic 
about going through 170 modules but I'm at a bit of a loose end at the 
moment, so I'm willing to do it.

There is of course a speed overhead but, to my surprise, benchmarks show that 
the relatively common

eval <<'EOM',
@ISA = ('Exporter');
@EXPORT      = qw(getservbyname getservbyport getservent getserv);
@EXPORT_OK   = qw( $s_name @s_aliases $s_port $s_proto );
use vars grep /^\$/, @EXPORT_OK;


eval <<'EOM',
use Exporter::Easy(   
  EXPORT => [qw(getservbyname getservbyport getservent getserv)],
  OK => [qw( $s_name @s_aliases $s_port $s_proto )],
  ALL => 'FIELDS',

take the same time .0007s. In other common cases Easy is about 50% slower but 
avoids having to list symbols twice.

Both of these are dominated by the cost of requiring an extra file but on my  

do ""

takes .0035s and

do "";do "Exporter/"

takes .0106s.

For this you get compile time error checking, much more flexibilty when 
building %EXPORT_TAGS and elimination of repetitive lists of symbols and 


Do you need someone with lots of Unix sysadmin and/or lots of OO software 
development experience? Go on, giz a job.
My CV -

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About