nested namespace
| From: | Greg Beaver | Date: | Fri, 07 Mar 2003 16:58:49 +0000 |
| Subject: | nested namespace | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-94896@lists.php.net to get a copy of this message | ||
Hi,
I'm wondering if a note of clarification could be added to ZEND_CHANGES. The sentences:
A namespace's name may contain colons to denote "sub-namespaces".
This is pure syntactic sugar, the Zend Engine will not see, for
instance, the namespaces "Package", "Package:Subpackage" and
"Package:Subpackage:Subsubpackage" as related.
will possibly be clearer if modified like:
A namespace's name may contain SINGLE colons (:) to denote "sub-namespaces". This is pure syntactic sugar, the Zend Engine
will not see, for instance, the namespaces "Package", "Package:Subpackage" and "Package:Subpackage:Subsubpackage" as related.
DOUBLE colons are used to distinguish between nested namespaces as in "Package::Subpackage." A namespace identifier may not begin with a colon.
namespace Package {
const one = 1;
namespace SubPackage {
const one = 'one';
}
}
namespace Package:Subpackage {
const one = 'einz';
}
echo Package::one; // 1
echo Package::Subpackage::one; // one
echo Package:Subpackage::one // einz
This is assuming I understand namespaces. Modify as needed.
Regards,
Greg