zealot has asked for the wisdom of the Perl Monks concerning the following question:
I started playing with this a bit, and found that the attribute specification would need to include the name to export the item as. Also, variables that are Exported should be readonly constants. That also seems to require some extra processing in my tests. So the above code would need to expand to the form:package Foo; use base qw( ExporterAttributes ); my $PI : Export_Ok = 3.14; sub utility : Export_Ok Export_Group(general) {...} sub another : Export_Ok Export_Group(general) {...} 1; ... use Foo qw( :GENERAL ); utility($bar);
Even with that extra overhead, this still would seem to be a nice method of exporting items from a package. Is this worth thinking about more, or is there something regarding how attributes are currently implemented that would make this less desirable. Daniel Rissepackage Foo; use base qw( ExporterAttributes ); use Readonly; my $PI : Export_Ok(PI); Readonly $PI => 3.14; sub utility : Export_Ok(utility) Export_Group(general) {...} sub another : Export_Ok(another) Export_Group(general) {...} 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Possible new module, Export using attributes
by venk (Acolyte) on Dec 22, 2005 at 19:34 UTC |