in reply to a question on namespaces and inheritance

A very interesting thread i must say.
I have two questions regarding this suggestion by japhy:
$obj->ChildClass2::method(...);

1. What would the (implicit) first parameter to the above call be, the class name ChildClass2 or the object $obj?

2. If the class name is being passed then thats no big deal because we could rather do this instead : ChildClass2::method(...);
If $obj is being passed as the first parameter to the subroutine call then i don't see much use of a concept such as inheritence at all as any method from other classes can be called like this: $obj->ChildClass2::method(...); as long as you have an object to some class.

Thanks in advance for all your answers.
  • Comment on Re: a question on namespaces and inheritance

Replies are listed 'Best First'.
Re^2: a question on namespaces and inheritance
by salva (Canon) on Jun 03, 2005 at 16:28 UTC
    $obj.

    $obj->ChildClass2::method(...) is almost identical to ChildClass2::method($obj, ...). The only difference is that it also looks for method on ChildClass2 parent classes.

      The only difference is that it also looks for method on ChildClass2 parent classes.

      It also allows you to use SUPER:: in the method.