AW: [PHP-DEV] A rebuttal to Re: RFC: Dropping Namespace
| From: | Matthias Pigulla | Date: | Fri, 07 Dec 2007 21:10:15 +0000 |
| Subject: | AW: [PHP-DEV] A rebuttal to Re: RFC: Dropping Namespace | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-33855@lists.php.net to get a copy of this message | ||
> Von: Gregory Beaver [mailto:greg@chiaraquartet.net]
> Exactly - which is why you should never put classes, functions or
> constants in the __php__ namespace. The convention I am proposing is
> to
> only use __php__ for code that *uses* re-usable components, not
> *declares* them.
Let alone __php__. If you just put all of your code into namespace Mylib, you're not safe
because according to the name resolution rules, internal classes come after imported ones but before
trying to find classes in the current namespace.
> 1) library code is always explicitly "use"d
> 2) name conflicts are impossible
1) is the crucial one because that puts your classes ahead of the internal ones in the resolution
list. That is not only "library code" you explicitly use, but also all code from
"your" own namespace. Having to explicitly enumerate all classes you use in your own
namespace in every file may be tedious.
So just to get that straight: Having a namespace statement and no "use" (because all you
use is from your library) is a discouraged practise?
Thanks!
-mp.