Re: Re: autoload with namespace

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

 



On Thursday 03 April 2008, Colin Guthrie wrote:
> Larry Garfield wrote:

> > 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.

See, I'm working on a different approach for Drupal.  We're actually scanning 
our own code base and building up an index of all classes (and functions!) in 
the system, saving that to the database, and then the autoload implementation 
just polls the database for the file that needs to be loaded and loads it.  
The class itself can literally live almost anywhere.  There's some more code 
on top of that for caching and routing optimization and such, but that's the 
basic idea and it's actually looking really sweet. :-)  It should be landing 
in HEAD very soon.

-- 
Larry Garfield			AIM: LOLG42
larry@xxxxxxxxxxxxxxxx		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
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