Paul Biggar wrote:
On Tue, May 12, 2009 at 9:43 AM, Dmitry Stogov <dmi...@zend.com> wrote:
Apologies, I'm not familiar with run-time inheritence in PHP. My
understanding was that when a classes source code is compiled, its
parent classes must be known. When is this not the case?
The parent class may be defined in other file that is loaded at runtime
using include() statement. It's very usual case. So the PHP first loads the
include file and then declares child class at runtime.

Must it be known for the class' first instantiation?
Of course. :)


On Tue, May 12, 2009 at 7:25 AM, Dmitry Stogov <dmi...@zend.com> wrote:
The real things is even worse as during compilation of a class it's parent
class doesn't have to be known. So construction of VMTs becomes a bit
problematic. BTW we could think in this way...


OK, so I dont understand this exactly. Is it correct to say that if a
class uses inheritance its compilation will be deferred until its
first instantiation? Or is it compiled when it is seen, and its parent
backpatched in later. When is later?

The classes which parent isn't known during compilation inherited at run-time by DECLARE_INHERITED_CLASS opcode. It patches property and method tablas, checks for method compatibility, etc

But I think its fair to say that it has static inheritance - that is,
its full inheritance chain is known before it can be instantiated, and
it can never be changed after that.

Right, but it has a lot of dynamic issues anyway. E.g. parent class may be changed or loaded from different file.


Thanks. Dmitry.





In the worst case, it _might_ be cheaper to build it at instantiation
time, but I would have to look up how expensive that is in a more
static language to be sure. Certainly, it is currently so expensive
that almost anything else would be better (including the OP's patch).
I don't see how run-time VMT contraction may help, because calls to virtual
method must know VMT offset at compile-time.

Right. Construction is fine. Their use is not. I don't know what I was
thinking.



So it looks like the best way forwards is still the OP's patch?



Thanks,
Paul




--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to