On 7/16/07, Stanislav Malyshev <[EMAIL PROTECTED]> wrote:
> The other thing that bothers me is namespaces nesting. It was said
> that namespaces
> nesting is not supported. Then I'm missing a point in having namespace
> named "A::B".
The same reason some people write $a = f($z, $t) and some write
$parsed_template = template_parser($template, $data_values) :)
I wasn't talking about a short/long names :-)
I was talking about a separator inside a namespace name.
> Lets say I have three files:
>
> a.php:
> <?php
> namespace A;
>
> function foo()
> {
> }
> ?>
>
> b.php:
> <?php
> namespace A::B;
>
> function bar()
> {
> //foo();
> }
> ?>
>
> index.php:
> <?php
> require 'a.php';
> require 'b.php';
>
> import A;
> foo(); // should call A::foo(), right?
> B::bar(); // will this call A::B::bar()?
> ?>
import A is a no-op. You do import A::B and then you can do B::bar.
import N means "something that is named N can now be referred only by
it's 'last name' last(N), last name being last segment of the long
name". If you have short names, you don't need namespaces, but if you
have names like PEAR::DB::Record::Type::Modifier::Exception, you
probably do :)
> Now if this does not work then whats the point in having namespace
> "A::B" instead of "A_B"? IMHO this brings more confusion then
> clearness.
The point is you can a) omit namespace prefix inside namespace and b)
use just B (or C if you wish) instead of A::B outside, once you did
import. As I said, with long names it makes sense, with short ones you
are OK without it.
a) I was talking about namespace name "A_B" not class/function 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?
Regards,
Giedrius
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php