in reply to Re: Inheritance - parent of parent
in thread Inheritance - parent of parent (solved)

Hmm..

Strange that the infinite loop don't occur.., good, but strange.

I must admit that I didn't try the code above myself,, but

copied the important parts from my real script, where it loops infinitly..

My assumptions about the infinite loop are because since the variable $class holds 'CLASS_C', so that calling

$class->SUPER::new();

would be the same as calling

CLASS_C->SUPER::new();

And the 'SUPER' of CLASS_C is CLASS_B, right?

So, shouldn't that result in new() in CLASS_B calling itself?

I've had kind of a good sleep, so now I'm going to look through my code again..

Thanks for the input so far =)

Replies are listed 'Best First'.
Re^3: Inheritance - parent of parent
by ikegami (Patriarch) on Nov 23, 2007 at 08:33 UTC

    No, SUPER is based on __PACKAGE__, not on ref($self). Quote perlobj,

    It is important to note that SUPER refers to the superclass(es) of the current package and not to the superclass(es) of the object.

    This is easy to demonstrate.

    { package Base; sub m { print("Boo!\n"); } } { package Child; our @ISA = 'Base'; bless({}, 'Anything')->SUPER::m(); # Boo! }