develooper Front page | perl.perl5.porters | Postings from December 2015

Re: Proposal: Add {-as => 'new_name'} feature to

Thread Previous | Thread Next
Chad Granum
December 18, 2015 04:55
Re: Proposal: Add {-as => 'new_name'} feature to
Message ID:
The problem is that it is very hard to do on the importing side. Once a sub
is entered into your namespace it is hard to undefine it. To make it go
away you have to delete the entire stash slot and put back the stuff you do
not want to get rid of. Also the rename functionality is usually for cases
where there is a conflict, so if you import both and rename after you have
to be careful of operation order.

That said I did write this just last night:

Take a look at the code to see how awful it actually is. On the other hand
doing it as an argument to import() provided by exporters is very simple.


On Thu, Dec 17, 2015 at 7:50 PM, Zefram <> wrote:

> Chad Granum wrote:
> >Several modern export tools such as Sub::Exporter and Exporter::Declare
> >make it possible to rename subs that you import.
> Appealing though such features are, the exporting side is the wrong place
> to do it, precisely because it would need to go into every exporter.
> Better to keep the exporter's obligations minimal, and address this
> on the importing side.  The facility can be written once to be applied
> regardless of exporter type, and it only need be invoked by importing
> modules that actually want to use the facility.
> -zefram

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