Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by tye (Sage)
on Mar 04, 2007 at 03:42 UTC ( #603101=note: print w/replies, xml ) Need Help??


in reply to Re^2: Inheritance and calling a subclass method *from* a baseclass method...
in thread Inheritance and calling a subclass method *from* a baseclass method...

I think the two primary pieces of information I would want in a "method should be overloaded" error message are the name of the method and the name of the class that didn't implement it. So I really think you need to report the latter (my $class= ref $self || $self;).

I'm not sure why you are writing code to look up the string "abstract_method" (perhaps so you can re-use this subroutine similar to *replace_me= \&abstrace_method;? -- no, doing so would still report "abstract_method" according to my testing, unfortunately). And, at least in this case, you don't even need to include the method name in the text since Carp::confess will already show that in the stack trace (though the error message is clearer if you do, of course). :)

- tye        

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

Replies are listed 'Best First'.
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

    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.

      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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2021-04-12 04:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?