On Thu, Jul 19, 2001 at 10:20:48PM +0100, Mark Maunder wrote:
> Also, calling SUPER:: on the original object wont allow you to propogate
> the call all the way up the heirarchy. If the parent then calls
> $self->SUPER:: it is calling itself.
No, it calls its parent. Try:
package Grandfather;
sub who_are_you { "I am Grandfather.\n" }
package Grandfather::Father;
use base qw(Grandfather);
sub who_are_you { shift->SUPER::who_are_you }
package Grandfather::Father::Son;
use base qw(Grandfather::Father);
sub who_are_you { shift->SUPER::who_are_you }
package main;
my $obj = bless({}, "Grandfather::Father::Son");
print $obj->who_are_you;
Notice the lack of an infinite loop.
> My problem is with $self that is retreived high up in the inheritance tree
> not being an object of the callers type, but rather of whatever type the
> caller got when it did a my $self = shift @_; At present I'm either using
> __PACKAGE__ or bless (to bless an object into the current package) to ensure
> that the called method gets a 'caller()' object type when doing my $self =
> shift @_; Is there a better way to do this?
This is as far as I understand your problem description. You have a method,
say Grandfather::Father::method(), that you're calling with a
Grandfather::Father::Son object. You want to call another method, on this
same object, but you want to bypass the Grandfather::Father::Son class.
Did I understand you correctly?
If so, why? What is it you're trying to accomplish with this? This type of
thing isn't normal, it sounds like you have some mis-designed classes.
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]