Re: [Zend Engine 2] Namespaces: - alternative
| From: | Wez Furlong | Date: | Wed, 28 May 2003 09:59:52 +0000 |
| Subject: | Re: [Zend Engine 2] Namespaces: - alternative | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-16766@lists.php.net to get a copy of this message | ||
Interesting idea.
I agree with Zeev and the others that namespaces just aren't that useful
if you don't have import (it causes too much typing and code obscurity).
This aliasing idea is essentially the same as import, but by limiting
the scope and changing the name we could probably make it work ;-)
I'd be +1 for Alans idea if it is feasible, and +0.5 on removing namespaces
if its not feasible (would still like to see them, but I understand the
issues).
--Wez.
On Wed, 28 May 2003, Alan Knowles wrote:
> class PEAR:This:is:The:Package {
>
> // this aliases " PEAR:This:is:The:Package" as _Package, so when
> ever the compiler sees _Package:.... in the
> // code it gets replaced at compile time with PEAR:This:is:The:Package
> // the _(underscore) prefix on Package is just a convention to
> prevent it clashing with a 'real' defined package/class.
> // could be used without (at your own risk...)
>
> alias as _Package;
>
> // note the scope of this alias is only limited to the class it is
> defined..
> // and the replacement is done at compile time only!
> While this is not use/import/namespace - it offers a solution to most of
> the issues faced by PEAR, and I would presume other large scale projects.
> - It's done at compile time. - hence little to no performance issues
> - It's minimally scoped.. - only affects methods inside classes. (and
> possible to pick up clashes at compile time - eg. alias to _XXXx, but
> _XXXX is already defined as a base package name'
> - It's not as much work :)
> - trades off the benifits of wildcard imports against the redability of
> aliasing.