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

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

Thread Next
Casey West
April 7, 2003 08:20
[PATCH] to call import() if the base->can()
Message ID:
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, 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
as a base class, for example, they shouldn't want the functions

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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About