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

[PATCH] base.pm to call import() if the base->can()

Thread Next
From:
Casey West
Date:
April 7, 2003 08:20
Subject:
[PATCH] base.pm to call import() if the base->can()
Message ID:
20030407152430.GA34510@geeknest.com
So sometimes base classes want to export things, constants and utility
functions among the more obvious things.  Sometimes they also want to
play around willy-nilly in the callers namespace.  This is not
possible when using base.pm, but only with the following.

  use Foo;
  push @ISA, 'Foo';

Why do all that when C<use base 'Foo';> should be simple enough?

So the following patch calls $base->import() only if it exists.  And
it's called empty, which would cause the default behaviour to occur.
I don't think it's useful to go as far as support multiple interfaces
and allow parameters to be passed in.  If someone wants to use CGI.pm
as a base class, for example, they shouldn't want the functions
exported.

This patch also cleans up the source.  There were some lines with
tabs, some with spaces, some with both.  It looked like the file
wanted to be four spaces indented, so that's what I made it.

Perl passes all tests on my Mac OS X platform, and my personal tests
pass as well.  Documentation and version number have been updated.
Patch attached.

  Casey West

-- 
Computers are useless. They can only give you answers. 
 -- Pablo Picasso


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