How many modules have you run across that do this?
package Foo; our @ISA = qw(Bar);
I believe that clobbering @ISA is wrong (though I'm occasionally guilty of it myself). The problem arises in that we sometimes may not know how @ISA has been modified before we clobber it. This is highly unlikely in the example above, but it could be an issue in a more complex class. Even if our current class won't give us problems, future changes could create problems.
Fortunatly, the use base pragma is just as easy to code for:
package Foo; use base 'Bar';
base will take care of munging @ISA for us, and has the additional effect of requireing the inherited package for us.
So please, leave @ISA alone. It might feel good, but it could bite you in the long run.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Avoiding the Use of @ISA = qw(Foo::Bar);
by chromatic (Archbishop) on Jul 14, 2003 at 18:07 UTC | |
•Re: Avoiding the Use of @ISA = qw(Foo::Bar);
by merlyn (Sage) on Jul 14, 2003 at 18:04 UTC | |
by hardburn (Abbot) on Jul 14, 2003 at 18:07 UTC | |
by merlyn (Sage) on Jul 14, 2003 at 18:08 UTC | |
Re: Avoiding the Use of @ISA = qw(Foo::Bar);
by dws (Chancellor) on Jul 14, 2003 at 18:14 UTC | |
Re: Avoiding the Use of @ISA = qw(Foo::Bar);
by Abigail-II (Bishop) on Jul 14, 2003 at 20:29 UTC | |
by Juerd (Abbot) on Jul 15, 2003 at 06:58 UTC | |
Re: Avoiding the Use of @ISA = qw(Foo::Bar);
by perrin (Chancellor) on Jul 14, 2003 at 19:09 UTC |