Home > Archive > PERL Miscellaneous > January 2008 > Can't call NEXT::f from B::g
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Can't call NEXT::f from B::g
|
|
| Victor Porton 2008-01-30, 7:18 pm |
| $ perl test.pl
Can't call NEXT::f from B::g at /home/porton/t/test2.pl line 10
Why the error?
#!/usr/bin/perl -w
use NEXT;
package A;
sub f { print "123\n" }
package B;
use base 'A';
sub g { shift->NEXT::f }
B->g;
| |
| Peter Makholm 2008-01-30, 7:18 pm |
| Victor Porton <porton@narod.ru> writes:
> $ perl test.pl
> Can't call NEXT::f from B::g at /home/porton/t/test2.pl line 10
>
> Why the error?
Doesn't the following except from the documentation to NEXT explains
it?
Note that it is a fatal error for any method (including "AUTOLOAD") to
attempt to redispatch any method that does not have the same name. For
example:
sub D::oops { print "oops!\n"; $_[0]->NEXT::other_method() }
//Makholm
| |
| Victor Porton 2008-01-30, 7:18 pm |
| On 30 Jan, 16:47, Peter Makholm <pe...@makholm.net> wrote:
> Victor Porton <por...@narod.ru> writes:
>
>
> Doesn't the following except from the documentation to NEXT explains
> it?
>
> Note that it is a fatal error for any method (including "AUTOLOAD") to
> attempt to redispatch any method that does not have the same name. For
> example:
>
> sub D::oops { print "oops!\n"; $_[0]->NEXT::other_method() }
Yes, that was my error.
New question: Why the below script does not print "123"?
#!/usr/bin/perl -w
use NEXT;
package A;
sub f { print "123\n" }
package B;
use base 'A';
package C;
use base 'B';
sub f { shift->NEXT::f }
C->f;
| |
| Michele Dondi 2008-01-30, 7:18 pm |
| On Wed, 30 Jan 2008 07:51:26 -0800 (PST), Victor Porton
<porton@narod.ru> wrote:
>package A;
>sub f { print "123\n" }
>
>package B;
>use base 'A';
Incidentally, base.pm does more than you expect. You may want to just
set @ISA manually in this case.
Moreover, base.pm is regarded as buggy by some.
Moreover, do not try to use B as a generic namespace, since it
actually exists. In fact when I stumbled upon your subject, I thought
it had to do with Perl's opcodes...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{po
p^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
|
|
|
|
|