binding) and anyway it only comes into play if you, for example, inherit from autoloaded class (then compiler can't runtime-bind the inherited class) but if you use autoloading on new(), etc. it doesn't matter at all.

Additionally, the non-autoloading example works better only in case like:

main.php:
include('a.php');
include('b.php');

a.php:
class Foo {}

b.php:
class Bar extends Foo{}

since by the time we get to b.php the engine already knows class Foo so it can immediately derive class Bar. However, if you have this code:

main.php:
include('a.php');
class Bar extends Foo {}

then it doesn't make any difference since class Bar can not be bould statically, autoload or not, since it needs include to run before it can do the binding.

Summing up, unless you are *very* careful with *all* parts of your application (and it is not simple to do it) and always keep track in your mind of what engine knows in each and every include scenario, you would have very hard time optimizing for always binding statically. I'd propose to forget about it and just use the interfaces PHP provides without trying to outsmart the engine. I would propose to still explicitly include the classes we know we would need (e.g. if you inherit from class or always use it, then do include it) using require_once in system components, and provide strong autoload mechanism so that the user could not bother with figuring out component dependencies and could use things like new $class() without worrying too much if that class is loaded.

--
Stanislav Malyshev, Zend Products Engineer
[EMAIL PROTECTED]  http://www.zend.com/

Reply via email to