Re: Question about Namespace patch
| From: | Larry Garfield | Date: | Tue, 24 Jul 2007 00:42:56 +0000 |
| Subject: | Re: Question about Namespace patch | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-31230@lists.php.net to get a copy of this message | ||
I'm fine with single-import-with-alias, from the descriptions here.
Effectively, then, there is no concept of "import". There is just an alias,
and mass-operation aliasing is quite messy.
I am more curious how far it goes in the supporting utilities. I saw that
there is a __NAMESPACE__ constant, which is nice. Is there also a way to get
the "full name" of a function or class, so you can see where it came from?
Does import work for functions as well as classes?
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
do that? Vis, is the callback type[1] namespace aware, or does it not have
to be?
(If this is already documented somewhere, please let me know where.)
[1]
http://us.php.net/manual/en/language.pseudo-types.php#language.types.callback
On Monday 23 July 2007, David Zülke wrote:
> That's exactly how import w/ aliasing is supposed to be used, you got
> that perfectly right.
>
>
> David
>
> Am 23.07.2007 um 20:40 schrieb Markus Fischer:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Hi Andrew,
> >
> > Andrew Minerd wrote:
> >> Well, first of all, not exactly. I think you meant: not import
> >> everything from two or more namespaces with conflicting names.
> >> Secondly, that's not the only solution. You could import
> >> everything from one, and not import from the other (or use a
> >> shorter prefix). Thirdly, you're not preventing collisions _at all_:
> >>
> >> import Zend::DB;
> >> import My::DB;
> >> import Woot::Database as DB;
> >
> > I don't quite understand your example. When I look at it in real
> > life, I
> > would go for:
> >
> > import Zend::DB as ZBD;
> > import My::DB as MDB;
> > import Woot::Database as DB;
> >
> > I mean, that's is the point, to have more readable code == shorter
> > identifiers, isn't it?
> >
> > So your code continues to read (just made up):
> >
> > $oZdb = ZDB::factor('mysql');
> > $oMdb = MDB::getInstance('oracle');
> > $oWdb = DB::getDriver('postgres');
> >
> > instead of:
> >
> > $oZdb = Zend::DB:factor...
> > $oMdb = My::DB::getInstance
> > $oWdb = Woot::Database::getDriver..
> >
> > Isn't that a win, at last?
> >
> > That's how I understood. Maybe I got that wrong.
> >
> > - - Markus
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.6 (MingW32)
> > Comment: Using GnuPG with Mozilla -
> > http://enigmail.mozdev.org
> >
> > iD8DBQFGpPYT1nS0RcInK9ARAmQmAKDGsYj/ZY0FNojQobKb3bK2NL6QDgCcDKgl
> > LnyIP65ymnx180f7/WD5WfM=
> > =LjpG
> > -----END PGP SIGNATURE-----
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List
> > To unsubscribe, visit: http://www.php.net/unsub.php
--
Larry Garfield AIM: LOLG42
larry@garfieldtech.com 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