On 24/07/12 16:35, Reeze wrote:
Hi, internals,
I'm proposing a improvement to namespace importing. when using 'use' statement
to import
many classes, we have to duplicate many times even we are importing from the
same namespace.
I propose a new syntax to import classes\functions\constant in a single
statement.
here is the example:
<?php
// reduce
use GlobalNamespace\SubSpace\ThirdSpace\Class1;
use GlobalNamespace\SubSpace\ThirdSpace\Class2;
use GlobalNamespace\SubSpace\ThirdSpace\ForthSpace\Class3;
// to
from GlobalNamespace\SubSpace\ThirdSace use Class1, Class2 as Alias2,
ForthSpace\Class3 as Alias3;
?>
The above code should be self-explained.
More info could be found at the RFC page and the patch.
RFC: https://wiki.php.net/rfc/namespace-importing-with-from
PATCH : https://github.com/reeze/php-src/compare/rfc-from-use
Any Opinion, suggestion, improvement will be much appreciated.
Thanks
Ah, so something a la python's from x import y, z? Sounds good. Somewhat
surprised we don't already have this.
One comment: "use Class1, Class2 as Alias2, ... ;" confuses me a bit. I
read it as "use (Class1, Class2) as Alias2, ... ;". //Perhaps this is
just a formatting issue (with newlines it would be more clear), but it
looks a little weird to me.
Just my 2¢.
--
Andrew Faulds
http://ajf.me/