Sorry for the second email, I just forgot to mention something regarding how
use statements apply from global scope to namespace x {}.
The best way regarding realworld usage and existing state of the art would
be to take into account the use statements in the scope above and apply the
use statements inside the scope after them.
So if I write this:
<?php
use A;
use B;
namespace {
use C;
}
?>
In the namespace, it's the same as if I wrote use A, B, C in that order
explicitly. Implemented this way, in a future version of PHP we could allow
this typical scenario (which I suspect won't work with this patch?):
<?php
use A;
function foo() {
use B; // use A applies implicitly, use B applied only for the scope of
the function
...code...
}
?>
Which code above is in fact a sugared version of what is actually happening:
<?php
use A;
function foo() { namespace {
use B; // use A applies implicitly, use B applied only for the scope
of the namespace scope
...code...
} }
?>
The above significantly helps with larger function/class libraries in a
single file, as you can make your use statements more local (typically you
will use certain classes globally, and most locally in a function/method),
and is supported by most modern languages that handle namespaces.
Regards, Stan Vassilev
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php