[test@test ~]$ perl -we ' package grand_father; use base qw/Class::Accessor::Fast/; sub new { my $class=shift; return $class->SUPER::new(@_); } package father; use base grand_father; sub new { my $self=shift->SUPER::new(@_); return $self; } package son; use base father; package main; use Data::Dumper; print Dumper(son->new);
output:
$VAR1 = bless( {}, 'son' );It seems to me the line my $self=shift->SUPER::new(@_); should cause dead loop,but it actually works fine.
My reasoning:
As SUPER should look up new in its parent ,so dead loop will occur.
Anyone can explain how SUPER works ?
In reply to Why doesn't SUPER cause dead loop here? by PerlOnTheWay
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |