Re: autoload with namespace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Larry Garfield wrote:
> On Wednesday 02 April 2008, Jochem Maas wrote:
> 
>>> there is one curiosity / caveat underlying the 5.3 implementation...  so
>>> does the namespace get supplied to the autoload function as well as the
>>> class name?  is it just one big string or are they separate?
>> one big string. how does php know before hand whether foo::get() is a
>> namespaced function call or a static class method call?
> 
> I believe the decision from -internals was "seriously, who uses static methods 
> and functions in the same code base that would use namespaces?"  Of course, I 
> would hope to be able to say "me!" once I am able to upgrade my work to 5.3, 
> but the debate over the separator character is one of those guaranteed to 
> start a flame war so I've just resigned myself to probably not being able to 
> use namespaces in most places.

While namespaces are neat and tidy, I personally currently adopt regexp
based autoload wrapper.

I basically define one autoload method (to rule them all) that consults
a list of "registered" autoloaders via a regexp (typically just a class
name prefix). It then calls the relevant autoload function for that class.

Sure this probably has a little more overhead than a 5.3 namespace based
approach, but it achieves most of the same end goals for me.

When hacking on other 3rd party apps that include such stuff it's
usually trivial to rewrite their autoloader to be a registration call to
the "universal autoloader" rather than a definition. Obviously it
requires the app in question to have a structure to their classnames tho'.

Col.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux