mab has asked for the wisdom of the Perl Monks concerning the following question:
This module is then used in several places throughout the application as:package Foo; sub new { ... }; sub xyzzy { ... }; 1;
Now I would like to subclass Foo but still use the class name Foo. That is, I don't want to subclass Foo as, say, Bar because this would require changes to all the references to Foo throughout the system - something that is undesirable for those implementations in which I do not want to subclass Foo. (Imagine Foo as being a system module used by other system modules.)require Foo; my $foo = new Foo ( ); print $foo->xyzzy ( );
And then set @INC to be:# The new Foo. package Foo; require System::Foo; @ISA = qw ( System::Foo ); ... 1;
So I'm willing to do this to the system objects but there's still a problem with those modules that do not have a custom subclass. That is, now all the places where I used the system module Bar as "require Bar" or "new Bar" have to be changed to "require System::Bar" and "new System::Bar." Well, that doesn't help at all as when I want to subclass Bar I would have to change these all back again.package System::Foo; ...
Edit kudra, 2002-06-06 s/pre/code/, added readmore
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: package namespaces
by IlyaM (Parson) on Jun 04, 2002 at 21:53 UTC | |
by mab (Acolyte) on Jun 04, 2002 at 21:54 UTC | |
|
Re: package namespaces
by perrin (Chancellor) on Jun 04, 2002 at 22:43 UTC | |
by mab (Acolyte) on Jun 05, 2002 at 01:52 UTC | |
by perrin (Chancellor) on Jun 05, 2002 at 03:28 UTC | |
by mab (Acolyte) on Jun 07, 2002 at 16:44 UTC | |
by perrin (Chancellor) on Jun 07, 2002 at 20:38 UTC |