|
Posted by J Krugman on January 13, 2005, 5:29 pm
Please log in for more thread options
Before I go off an file a bug report, I want to make sure that I
got things right. In the SYNOPSIS section for Damian Conway's NEXT
module's POD, there's the following extended example:
use NEXT;
package A;
sub A::method { print "$_[0]: A methodn"; $_[0]->NEXT::method() }
sub A::DESTROY { print "$_[0]: A dtorn"; $_[0]->NEXT::DESTROY() }
package B;
use base qw( A );
sub B::AUTOLOAD { print "$_[0]: B AUTOLOADn"; $_[0]->NEXT::AUTOLOAD() }
sub B::DESTROY { print "$_[0]: B dtorn"; $_[0]->NEXT::DESTROY() }
package C;
sub C::method { print "$_[0]: C methodn"; $_[0]->NEXT::method() }
sub C::AUTOLOAD { print "$_[0]: C AUTOLOADn"; $_[0]->NEXT::AUTOLOAD() }
sub C::DESTROY { print "$_[0]: C dtorn"; $_[0]->NEXT::DESTROY() }
package D;
use base qw( B C );
sub D::method { print "$_[0]: D methodn"; $_[0]->NEXT::method() }
sub D::AUTOLOAD { print "$_[0]: D AUTOLOADn"; $_[0]->NEXT::AUTOLOAD() }
sub D::DESTROY { print "$_[0]: D dtorn"; $_[0]->NEXT::DESTROY() }
package main;
my $obj = bless {}, "D";
$obj->method(); # Calls D::method, A::method, C::method
$obj->missing_method(); # Calls D::AUTOLOAD, B::AUTOLOAD, C::AUTOLOAD
# Clean-up calls D::DESTROY, B::DESTROY, A::DESTROY, C::DESTROY
Contrary to what the comments above say, when I run this example,
the output that I get is
D=HASH(0x8118164): D method
D=HASH(0x8118164): C method
D=HASH(0x8118164): D AUTOLOAD
D=HASH(0x8118164): B AUTOLOAD
D=HASH(0x8118164): C AUTOLOAD
D=HASH(0x8118164): D dtor
D=HASH(0x8118164): B dtor
D=HASH(0x8118164): C dtor
Neither A::method nor A::DESTROY is ever called. Also, I found
the following on Google Groups:
use strict;
use warnings;
package Foo;
use NEXT;
sub new { bless {}, 'Foo' }
sub AUTOLOAD { (shift)->NEXT::ACTUAL::AUTOLOAD(@_); }
package main;
my $f = Foo->new();
$f->bar(); # should trigger an error but doesn't
Foo->baz(); # ditto
Indeed, NEXT fails to trigger the errors it's supposed to.
What's the story? Is NEXT really as broken as it looks, or am I
missing something? My version of Perl is 5.8.4 and my version of
NEXT is 0.60 (the latest one available from CPAN).
TIA!
jill
--
To s&e^n]d me m~a}i]l r%e*m?ov[e bit from my a|d)d:r{e:s]s.
|
|
Posted by Jim Keenan on January 14, 2005, 1:11 am
Please log in for more thread options
J Krugman wrote:
> Before I go off an file a bug report, I want to make sure that I
> got things right. In the SYNOPSIS section for Damian Conway's NEXT
> module's POD, there's the following extended example:
> [snip excerpt from NEXT POD]
>
> Contrary to what the comments above say, when I run this example,
> the output that I get is
>
> D=HASH(0x8118164): D method
> D=HASH(0x8118164): C method
> D=HASH(0x8118164): D AUTOLOAD
> D=HASH(0x8118164): B AUTOLOAD
> D=HASH(0x8118164): C AUTOLOAD
> D=HASH(0x8118164): D dtor
> D=HASH(0x8118164): B dtor
> D=HASH(0x8118164): C dtor
>
> Neither A::method nor A::DESTROY is ever called.
I confirm your results and share your puzzlement -- but I don't know
enough about/haven't enough used multiple dispatch to be able to
diagnose the problem.
jimk
|
|
Posted by Jim Keenan on January 15, 2005, 3:02 am
Please log in for more thread options J Krugman wrote:
> Before I go off an file a bug report, I want to make sure that I
> got things right. In the SYNOPSIS section for Damian Conway's NEXT
> module's POD, there's the following extended example:
>
>
[snip]
Since no one here came up with an answer, I took the liberty of posting
the first part of the problem on Perlmonks. The answer (from Friar !1):
It's a documentation bug. Damian shouldn't have used 'B' for a
package name because 'B' is special to Perl ... all those bizarre B::*
modules.
See the Perlmonks node beginning at:
http://www.perlmonks.org/index.pl?node_id=422324
Jim Keenan
|
|