Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: Inheritance and calling a subclass method *from* a baseclass method... (error data)

by izut (Chaplain)
on Mar 04, 2007 at 12:36 UTC ( #603112=note: print w/replies, xml ) Need Help??


in reply to Re^3: Inheritance and calling a subclass method *from* a baseclass method... (error data)
in thread Inheritance and calling a subclass method *from* a baseclass method...

Actually the abstract_method name was used as example. Maybe was better if I used your_abstract_method_here or something.

Igor 'izut' Sutton
your code, your rules.

  • Comment on Re^4: Inheritance and calling a subclass method *from* a baseclass method... (error data)
  • Select or Download Code

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

    I wasn't particularly confused on that point and another choice of example name wouldn't have eliminated my question: Why would you choose to write:

    sub whatever { #... my ($method) = ( caller(0) )[3]; #... }

    when it appears to be functionally equivalent to the trival and thus clearer:

    sub whatever { #... my $method= "whatever"; #... }

    - tye        

      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.

        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        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://603112]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2021-02-26 12:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?