On Tuesday 24 July 2007, Andrew Minerd wrote:
> On Tue, 24 Jul 2007 11:53:38 -0700
>
> [EMAIL PROTECTED] (Stanislav Malyshev) wrote:
> > > Where I can see a huge use for namespaces is plugin-based
> > > architectures.  Each plugin is its own namespace.  If you have a list
> > > of plugins, then you have a list of namespaces and can iterate over
> > > that and invoke the same operation on each plugin.  That would require
> > > call_user_func() and call_user_func_array() and the rest of that family
> > > to be able to handle namespaces.  How would one
> >
> > Since namespace is just a part of class name, I don't see any problem
> > for call_user_func() to be able to use namespaced names. Of course, they
> > should get full class name - if you want to use shorter ones you'd have
> > to change something. Here we might need some functionality, but it's not
> > clear to me yet which one.
>
> w/ snapshot from yesterday:
>
> [EMAIL PROTECTED] /usr/local/src/php6.0-200707232030 $ cat ./namespace3.php
> <?php
> namespace test;
>
> class Blah { static function test() { echo "Test\n"; } }
>
> call_user_func(array(__NAMESPACE__.'::Blah', 'test'));
> ?>
>
> [EMAIL PROTECTED] /usr/local/src/php6.0-200707232030 $ ./sapi/cli/php
> ./namespace3.php Test

Mm, nice.  And presumably the same would work for any other namespace, and for 
functions as well as classes/objects.

That should make plugin architectures, both OO and non-OO, a lot cleaner.  
Spiffy. :-)

Do __autoload() and the SPL autoload stack get namespace information as well?  
I didn't get that from the mail archive link posted yesterday.

-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               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 Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to