RE: [PHP-DEV] Re: [PHP-WEBMASTER] Why isn't `spl_autoload` called for functions?
| From: | Laupretre François | Date: | Tue, 06 Nov 2012 23:57:14 +0000 |
| Subject: | RE: [PHP-DEV] Re: [PHP-WEBMASTER] Why isn't `spl_autoload` called for functions? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-63770@lists.php.net to get a copy of this message | ||
> De : sebastian.krebs.berlin@gmail.com
> > I hope you find more support on this than I had. Technically
> speaking,
> > it would be easy to extend autoloading to functions and constants. It
> > can even be done without BC breaks, combining 'old-style' and 'new-
> style'
> > autoloaders without ambiguity (adding a second argument to the
> > autoload hook, and checking the number of args declared by the
> function).
> >
>
> Thats not even required, if you fixate (--> default value) the second
> parameter to "class" all existing loaders will behave, like they did
> before.
Correct, but that's not enough to preserve BC.
OK, giving a default value of 'class' to the second arg allows using a
'new-style' autoloader with an 'old-style' PHP engine.
But, now consider the opposite, using a 'new-style' PHP engine, with autoloading extended
to functions and constants, with one or more 'old-style' autoloaders: when the engine
needs to autoload a function or a constant, we must not call any 'old-style' autoloader,
as it would take the symbol and attempt to load a class by that name. And the easiest way to decide
if an autoloader is a new or old-style one is to check if the autoload handler func is declared with
one or two args.
François