Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

•Re^8: goto superclass method

by merlyn (Sage)
on Dec 23, 2004 at 00:22 UTC ( [id://416966]=note: print w/replies, xml ) Need Help??


in reply to Re^7: goto superclass method
in thread goto superclass method

Well, I think the main reason your code is broken is this:
goto $_[ 0 ]->SUPER::can( 'method' );
I have no idea how this even parses, unless it's interpreted as "go to the label that matches the stringification of the result of this expression". You're missing the necessary &{ .. }. So, either that isn't the code you're running, or something Very Weird is going on.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^9: goto superclass method
by Aristotle (Chancellor) on Dec 23, 2004 at 00:26 UTC

    goto seems to do the expected thing when you give it a coderef.

    $ perl -le'my $foo = sub { print "bar" }; sub x { goto $foo } print "$ +foo"; x' CODE(0x813bc08) bar

    I don't think there's any doubt about what's happening here.

    Oh, also, none of my previous examples change at all in behaviour if you use the goto &{ ... } notation instead.

    Makeshifts last the longest.

      Well, then, we're back to my other explanation. You're not calling can("SUPER::bar"). You're calling SUPER::can("bar"), so you're finding yourself. Don't do that. Stop saying SUPER::can. It means practically nothing other than "can", unless you have a "can" method in the current class.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        Something must have gotten lost along the way, because the fact that $self->SUPER::can("bar") is (usually) the same as $self->can("bar") is exactly what I was saying in the very first post… :-) (It can only be different if there is a can in one of the superclasses though, regardless of whether there is one in the current class.)

        Basically, I pointed out one of my two mistakes, then explained why it was a mistake, and came up with a broken solution because I missed something I thought I hadn't (that you can ask UNIVERSALL::can about 'SUPER::method'). Then you came along and pointed out my other mistake as well, but said that it somehow invalidated my correct explanation for the mistake I had already spotted.

        Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-16 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found