http://qs321.pair.com?node_id=603135


in reply to Re^5: Inheritance and calling a subclass method *from* a baseclass method... (rephrase)
in thread Inheritance and calling a subclass method *from* a baseclass method...

You are totally right. I thought that caller use the package name that inherits the owner of abstract method, but it doesn't. Sorry about the confusion :-)

Igor 'izut' Sutton
your code, your rules.

  • Comment on Re^6: Inheritance and calling a subclass method *from* a baseclass method... (rephrase)
  • Download Code

Replies are listed 'Best First'.
Re^7: Inheritance and calling a subclass method *from* a baseclass method... (rephrase)
by tye (Sage) on Mar 04, 2007 at 21:49 UTC

    Thanks. That made me realize my mistake. I was overlooking that caller would return __PACKAGE__."::methodName" not just "methodName".

    Yes, it'd be nice if caller offered information about under what name the function was called instead of just under what name the function was compiled.

    It'd be nice if the following code:

    package Source; sub orig { # use caller() here } package Importer; @ISA= "Parent"; *dest= \&Source::orig; package main; Parent->dest();

    Would be able to determine that the caller was trying to find "Parent::dest", found "Importer::dest" via inheritance, and that function which was compiled under the name "Source::orig", rather than only being able to find out that last item.

    - tye