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

Re: [PATCH] UNIVERSAL shouldn't require Exporter

Thread Previous | Thread Next
From:
Graham Barr
Date:
April 26, 2001 06:51
Subject:
Re: [PATCH] UNIVERSAL shouldn't require Exporter
Message ID:
20010426145004.N64737@pobox.com
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 UNIVERSAL;
  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
}

Graham.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About