Re: Simple Namespace Proposal

From: Date: Mon, 16 Jul 2007 17:31:03 +0000
Subject: Re: Simple Namespace Proposal
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-30988@lists.php.net to get a copy of this message
On 7/16/07, Stanislav Malyshev <stas@zend.com> wrote:
a) I was talking about namespace name "A_B" not class/function name. _ is legal identifier character, so it would not be a good idea to use it as a separator. :: on the other side is natural scope separator in many languages. But I'm rather reluctant to start the "my separator is better than yours" thread for the 42th time :)
Me neither :-) :: is perfectly good for me. I just missed the point of having it more then once if it's only purpose is to separate default short name part from whole name.
b) So as far as I understand "import" doesn't actually *import* names from specified namespace to the current one but just renames long namespace name to a shorter one. And if I get it right the separator in the namespace name is allowed and required only to express default name when importing without "as". Am I right? Not exactly. It does import, but not names just one name - the very same name it has as an argument. The :: is used to join components of the name. Note that you can also do: import Foo::XML as myXML; $a = new myXML::Data::Document();
Now that explains a lot :-) If I get it right I can have namespaces A::B::C and A::B::D then create an alias for A::B with "import A::B" and use B::C::foo() and B::D::foo() in that file. Thats nice. Looks like namespace nesting though it isn't :-) Regards, Giedrius

« previous php.internals (#30988) next »