"Jonathan Mangin" <suppressed> wrote on 11/17/2006 04:12:11
PM:
> I have a package that begins:
>
> package MyApp::Tests;
>
> use base 'MyApp::Base';
> use CGI::Carp qw(fatalsToBrowser);
>
> I previously had the CGI::Carp line in Base.pm, and realized
> fatalsToBrowser() was not working. I thought that all methods
> available to Base would be available in Tests. Is that right?
> C::A::Plugin::TT methods are, though 'used' in Base. Or am
> I doing something wrong?
I had wanted/expected the inheritance to work the same way you indicated,
but it doesn't.
Programming Perl, Third Edition:
31.3. use base
use base qw(Mother Father);
This pragma lets a programmer conveniently declare a derived class based
upon the listed parent classes. The declaration above is roughly
equivalent to:
BEGIN {
require Mother;
require Father;
push @ISA, qw(Mother Father);
}
The use base pragma takes care of any require needed. When the strict
'vars' pragma is in scope, use base lets you (in effect) assign to @ISA
without first having to declare our @ISA. (Since the use base pragma
happens at compile time, it's best to avoid diddling @ISA on your own at
run time.)
28.2. Special Variables in Alphabetical Order
@ISA
[PKG] This array contains names of other packages to look through when
a method call cannot be found in the current package. That is, it contains
the base classes of the package. The use base pragma sets this implicitly.
It is not exempt from use strict. See Chapter 12, "Objects".
So, my interpretation is that @ISA only works for methods (ie,
$self->method()) and CGI::Carp is importing into the current package and
doing subroutine calls.
Todd Ross
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.