Matthias Pigulla wrote:
Now that was a quick reply :)
Also known as runtime inheritance, or late binding. It's not a new
thing, we have it today. The discussion was about whether to
have a way
...
That is, one can write
if (...) class A extends X {} else class A extends Y {}
right now? Seriously ;)?
Every now and then I'm surprised what weird sort of stuff is allowed in
PHP :), but most probably you don't really want to write this sort of
code in the first place? ;)
Well, or do a conditional include or an include_once and you end up
having to do late binding too. It doesn't have to be as weird as your
example, but yes, that works too.
Just like any other signature in an instance, it tells anything that
implements the interface that it must have a constructor and that
constructor must meet the definition in the interface. Useful for
object factories. In most cases you don't want to force a specific
constructor in which case you wouldn't specify it in the
interface, but
I see no reason why you shouldn't be allowed to specify it
there if you
want to.
The point is that interfaces are nothing you could anything with - that
is, if you have "something" that implements an interface, it has already
been constructed. You never construct instances through an interface
(you would have to choose an implementation, the interface isn't one)...
I just cannot explain it in a better way ;) It's somewhat similar to
that you cannot make static calls on interfaces.
I don't see why you can't specify that a class definition must have a
constructor. Obviously the constructor is not for the interface itself.
-Rasmus
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php