in reply to Re: goto superclass method
in thread goto superclass method
This is an infinite loopIt's an infinite loop, but not for the reasons you state. SUPER:: is always relative to __PACKAGE__, and when you start saying sub Foo::bar, the __PACKAGE__ doesn't change to Foo, so you have a problem with SUPER.
In short, Don't Do That. Properly written code works properly:
package Base; sub do_me { my $self = shift; print "Base do_me\n"; } package Derived; @ISA = qw(Base); sub do_me { my ($self) = @_; # no shift, so we can goto print "About to jump...\n"; goto &{$self->can("SUPER::do_me")}; } package main; Derived->do_me;
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: goto superclass method
by Aristotle (Chancellor) on Dec 22, 2004 at 21:49 UTC | |
by merlyn (Sage) on Dec 22, 2004 at 23:19 UTC | |
by Aristotle (Chancellor) on Dec 22, 2004 at 23:48 UTC | |
by merlyn (Sage) on Dec 22, 2004 at 23:53 UTC | |
by Aristotle (Chancellor) on Dec 23, 2004 at 00:14 UTC | |
| |
Re^3: goto superclass method
by steves (Curate) on Dec 22, 2004 at 21:41 UTC | |
by Aristotle (Chancellor) on Dec 22, 2004 at 21:50 UTC | |
Re^3: goto superclass method
by Mr. Muskrat (Canon) on Dec 22, 2004 at 22:00 UTC |
In Section
Seekers of Perl Wisdom