What happens if you mix them?
<?php
namespace baz;
namespace foo {
class Bar {
...
}
}
?>
That's not the fun yet. This is:
<?php
namespace baz;
namespace foo { ...whatever... }
class bar {}
?>
Now, is bar in namespace baz or not? I guess it is, otherwise it stops
making any sense. So now when you see in the code it says "class bar"
what do you do to know which namespace it is? Right, you go up to the
code, counting closing and open brackets and hoping you didn't miss any
and try to figure out if it's that main namespace or one of the other
ones. Now next question - how ones in namespace foo are supposed to call
class bar? They'd have to call it by full name, baz::bar, right? Welcome
back, long names. But wait, we could use an import, right? So now we'd
have block-local imports. And we'd have to track them per
namespace-block. BTW, what about imports in baz - are they active in
foo? What if baz wants to talk to class in foo - should it import it?
And BTW - how the patch solves it - I didn't read all of it, but not
sure it does it correctly.
Would the compiler have a heart attack if someone did:
<?php
namespace foo {
namespace baz {
class Bar { ... }
}
}
?>
This syntax implies that baz has access to names in foo. The separate
syntax doesn't. But that's only part of the story - remember the
names/imports story above? Now take that and make it unlimited depth
stack, since you'd have to track everything on *each* nesting level
separately. I wouldn't want to open this can of worms. That'd produce
messy engine and messy code.
--
Stanislav Malyshev, Zend Software Architect
[EMAIL PROTECTED] http://www.zend.com/
(408)253-8829 MSN: [EMAIL PROTECTED]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php