Sorry, just read the rest of your message.

Sortof. Grandfather has some utility methods in it that Son and Father both
use. Son calls a method (call it save() )which it has defined. Within this
method it uses one of the utility methods (lets call it
Grandfather::get_name() ) defined within grandfather. Once Son::save() has
finished doing its own stuff, it calls $self->SUPER::save() to call
Father::save(). Father::save() also uses the same utility method defined
within Grandfather i.e. Grandfather::get_name().

Now the problem is that  Grandfather::get_name() calls
$self->_list_attributes() and expects that method to call _list_attributes()
within the caller of Grandfather::get_name(). i.e. when Father::save() calls
Grandfather::get_name() and Grandfather::get_name calls
$self->_list_attributes() it expects Father::_list_attributes to be called.
This is not the case because the original calling object is of type Son i.e.
ref($self) within Grandfather::get_name returns 'Son'.

Therefore the only was for Father::save() to call Grandfather::get_name is
by doing:
__PACKAGE__->get_name()
which will then give Grandfather::get_name an object of type Father an which
in turn will allow Grandfather::get_name to access
Father::_list_attributes()

I dont think that this is an abnormal thing to do. I'm pretty sure that
classes up and down a class heirarchy normally access methods from a
'senior' class (after being called from a 'junior' class) that in turn
expect to be able to access data (via a data access method) in the calling
class.

Perhaps I should just stick to the standard paradigm of passing $self as it
was received from 'my $self = shift @_;' to any called methods by doing a
$self->methodname(), and instead use the caller() function in the method
that exists in the class close to the top of the heirarchy (i.e.
Grandfather::get_name() in the above example) to access data in the caller.



>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.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to