Re: difference between "use base" and @ISA?
by CountZero (Bishop) on Aug 25, 2005 at 15:57 UTC
|
From the docs:use base qw(Foo Bar);
Roughly similar in effect to
BEGIN {
require Foo;
require Bar;
push @ISA, qw(Foo Bar);
}
Will also initialize the fields if one of the base classes has it.
Multiple Inheritence of fields is NOT supported, if two or more
base classes each have inheritable fields the 'base' pragma will
croak. See fields, public and protected for a description of
this feature.
When strict 'vars' is in scope, base also lets you assign to @ISA
without having to declare @ISA with the 'vars' pragma first.
If any of the base classes are not loaded yet, base silently
requires them (but it won't call the import method). Whether to
require a base class package is determined by the absence of a global
$VERSION in the base package. If $VERSION is not detected even after
loading it, base will define $VERSION in the base package, setting it to
the string -1, set by base.pm.
CountZero "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
| [reply] [d/l] [select] |
Re: difference between "use base" and @ISA?
by BaldPenguin (Friar) on Aug 25, 2005 at 16:48 UTC
|
| [reply] |
Re: difference between "use base" and @ISA?
by friedo (Prior) on Aug 25, 2005 at 15:56 UTC
|
BEGIN {
require 'Foo';
@ISA = ('Foo');
}
Does that work? base does its @ISA munging at compile-time, so CGI::Application::Plugin::AutoRunmode may be dependent on that. | [reply] [d/l] [select] |
|
@ISA = ('Foo'); will destroy whatever was already in @ISA and will surely break a lot of other things depending on that array.
CountZero "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
| [reply] [d/l] [select] |
|
My understanding has always been that @ISA is a package global, so the only way it would have something in it is if it were set elsewhere in the same package, which would be a pretty strange thing to do. In other words, it's safe to overwrite it in your own package. I think friedo's code is fine, but I'd be happy to learn otherwise if there's something I'm missing.
| [reply] [d/l] |
Re: difference between "use base" and @ISA?
by davidrw (Prior) on Aug 25, 2005 at 16:57 UTC
|
And also (from a simple search of "use base isa"):
| [reply] |
Re: difference between "use base" and @ISA?
by Tanktalus (Canon) on Aug 26, 2005 at 04:19 UTC
|
Mark, there's nothing I see in CGI::Application::Plugin::AutoRunmode that points to use base working or not working that I can see. Perhaps a snippet of your module that exhibits the same problem, and a better description of the symptoms you're facing may be in order? You may have misdiagnosed the problem here. Not that you aren't getting good answers to the question you asked, but the question may not be actually related to your problem.
Thanks,
| [reply] |
|
To be clear, my problem is not getting my application to work. "use base" works for me. I want to learn the about the differences to make intelligent choices in the future. And thanks to the many helpful responses, I think I've got a chance of figuring this out. Thanks all!
| [reply] |
|
| [reply] [d/l] [select] |