Hi, I've been furiously working behind the scenes with Stas and Dmitry, and have some enhancements to namespaces in the form of 2 patches.
1) multiple namespaces per file 2) use ::name; 1) multiple namespaces per file This is implemented as such: <?php namespace one; use Blah::A; // code namespace two; use Foo::A; ?> The example above shows that imported names are reset at each namespace declaration. There is no prohibition on this code: <?php namespace one; { use Blah::A; // code } namespace two; { use Foo::A; // code } ?> Users who wish to use brackets may do so. The performance penalty imposed by using brackets is minor for some cases, and for users who are following the recommended practice of 1 namespace per file, the syntax is ideal. Patch is: http://pear.php.net/~greg/namespace/PHP_5_3/multi.patch.txt http://pear.php.net/~greg/namespace/PHP_6_0/multi.patch.txt Note that non-namespaced code cannot be present in a file containing namespaces. For users who are bundling, this will mean you will need to create 2 files, one with non-namespaced code, and one with namespaced code. This minor prohibition is a design decision, not a technical problem in the implementation. 2) use ::name This code: <?php namespace Whatever; use MDB2; // import PEAR's ::MDB2 from global scope $a = MDB2::connect(); ?> is currently impossible, which will make namespacing old code harder. The patch introduces this new syntax to import names from the global namespace: <?php use ::MDB2, ::strlen as len; ?> http://pear.php.net/~greg/namespace/PHP_5_3/use.patch.txt http://pear.php.net/~greg/namespace/PHP_6_0/use.patch.txt These patches are for review of both serious technical and serious implementation issues. In order to help move things along, I'd like to define "serious" as something directly related to the implementation that would cause a failure in PHP's ability to run scripts deterministically, or some kind of memory leak/crash. commit is planned for the next 24 hours or so, but of course any issues found in review can be fixed. The patches are short, so in the worst case, reverting is not difficult. Thanks, Greg -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php