Re: RE: __init magic method
| From: | Rasmus Lerdorf | Date: | Wed, 23 Jan 2013 03:37:21 +0000 |
| Subject: | Re: RE: __init magic method | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-65105@lists.php.net to get a copy of this message | ||
On 01/22/2013 07:20 PM, Dmitri Ravazin wrote:
> hey, here's an idea. Let's drop class autoloading 'magic' as well,
> because it has all the same 'problems' that you've just described.
> It loads things at 'completely arbitrary' times, it's complicated, and
> it surely makes reading code 'too hard'. And the gains are 'very
> little', anyway.
> You can always load your classes manually with a bunch of require
> statements, right?
It is trickier than autoloading because __init() tries to blur the lines
between the compile and execute stages if I read your original email
correctly. And we have some magic in the compiler that tries to optimize
things and resolve as much of the inheritance chain as possible at
compile-time to the point where ZEND_FETCH_CLASS opcodes are NOP'ed
away(*). I suppose this could still hang off of the the initial
ZEND_FETCH_CLASS for a class, but it would definitely get tricky to
determine when this would happen.
(*) http://lxr.php.net/xref/PHP_5_4/Zend/zend_compile.c#4444
-Rasmus