develooper Front page | perl.perl5.porters | Postings from April 2001

Re: [PATCH] UNIVERSAL shouldn't require Exporter

Thread Previous | Thread Next
Graham Barr
April 26, 2001 06:51
Re: [PATCH] UNIVERSAL shouldn't require Exporter
Message ID:
On Thu, Apr 26, 2001 at 02:37:12PM +0100, Simon Cozens wrote:
> On Thu, Apr 26, 2001 at 01:58:34PM +0100, Mike Guy wrote:
> >      These subroutines should not be imported via
> >      "use UNIVERSAL qw(...)". 
> What was the rationale for this statement?

Action at a distance.

If you have a module which does not have or inherit import
(eg SelectSaver)

  use SelectSaver qw(foobar);

silently ignores the qw(foobar)

  use SelectSaver qw(foobar);

dies, because every module now inherits Exporter.

Also the nature of UNIVERSAL is to supply default methods for all classes,
not export things.

In fact this should be fixed with something like

sub import {
  return unless $_[0] eq 'UNIVERSAL';
  require Exporter;
  goto &Exporter::import


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