RE: [PHP-DEV] Simple Namespace Proposal
| From: | Dmitry Stogov | Date: | Mon, 23 Jul 2007 14:44:58 +0000 |
| Subject: | RE: [PHP-DEV] Simple Namespace Proposal | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-31191@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: david.coallier@gmail.com
> [mailto:david.coallier@gmail.com] On Behalf Of David Coallier
> Sent: Monday, July 23, 2007 4:31 PM
> To: Dmitry Stogov
> Cc: Arpad Ray; Hans Lellelid; PHP internals
> Subject: Re: [PHP-DEV] Simple Namespace Proposal
>
>
> On 7/23/07, Dmitry Stogov <dmitry@zend.com> wrote:
> > Hi Arpad,
> >
> > You have to always use namespace name as prefix for acesing
> namespace
> > entities. (The only exception is direct import of calss).
> > So expectatins in your tests are wrong.
> >
> > Thanks. Dmitry.
> >
> > > -----Original Message-----
> > > From: Arpad Ray [mailto:arpad@rajeczy.com]
> > > Sent: Sunday, July 15, 2007 7:32 PM
> > > To: Dmitry Stogov
> > > Cc: 'Hans Lellelid'; 'PHP internals'
> > > Subject: Re: [PHP-DEV] Simple Namespace Proposal
> > >
> > >
> > > Dmitry Stogov wrote:
> > > > The patch is already committed to the HEAD.
> > > >
> > > > Dmitry.
> > > >
> > > There seem to be some problems with importing across files. The
> > > tests currently in CVS are all in single files so it's not
> > > immediately obvious. When a namespace is declared in one file and
> > > imported in another, classes must be addressed absolutely
> either in
> > > the import or when used, and functions must be addressed
> absolutely
> > > when used, irrespective of imports.
> > >
> > > I've attached some phpt files to test this, but here's a simple
> > > illustration:
> > >
> > > foo.php:
> > > <?php
> > > namespace foo;
> > > function foobar() { }
> > > class Foobaz { }
> > > ?>
> > >
> > > bar.php:
> > > <?php
> > > import foo;
> > > foobar(); // error
> > > new Foobaz; // error
> > > foo::foobar(); // ok
> > > new foo::Foobaz; // ok
> > >
> > > import foo::foobar;
> > > import foo::Foobaz;
> > > foobar(); // error
> > > new Foobaz; // ok
> > >
> > > import foo::foobar as foobar2;
> > > foobar2(); // error
> > > ?>
> > >
> > >
> > > Arpad
> > >
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> Ok here are a few questions that I would like clear answers
> and not "Do you have a proposal? I DON"T SEE ONE, do you have
> a patch??. I just want a simple but clear answer.
>
>
> 1) Do we have unnamed namespaces available ?
What is "unnamed namespace"?
We have global namespace that contains all PHP internal function/classes and
user defined function/classes in files without namespace declaration.
>
> 2) In short and clear, why are braces not being used ? C++,
> C# uses it. (Short answer and if the answer is "Developer
> didn't want to do it..." just say "Usual"
We are not C++. Python doesn't use braces.
The only neediness for braces is placing several namespaces into one file,
but one of the goal of our concept is avoiding this.
>
> 3) Do we have aliasing available ? (Ex: namespace PHP_NSX =
> PHP_NS1::PHP_NS2)
The import statement creates alias.
"import PHP_NS1::PHP_NS2 as PHP_NSX;" does exacly what you want.
"import PHP_NS1::PHP_NS2;" really does ""import PHP_NS1::PHP_NS2 as
PHP_NS2;".
>
> 4) Are nested namespaces available ?
>
No they are.
> 5) Were there any test provided with such feature commit ? If
> so where could I see them to use them and maybe answer my own
> questions (And I do not have time to read through all the
> patch to see if it does)
Look into Zend/tests/ns_*.phpt
>
> Should be ok for a first draft and this is not some sort of
> attack, I am really trying to compile a list of features
> absent and present to see what *types* of namespaces we have
> and how to correctly inform people on how to use them.
It is not the first namespace proposal.
I made three different concept and saw two other concepts in the past .
This one seems as most awaitble by most PHP users.
Thanks. Dmitry.
> --
> David Coallier,
> Founder & Software Architect,
> Agora Production (http://agoraproduction.com)
> 51.42.06.70.18
>