On 05.11.2008, at 00:12, Marcus Boerger wrote:
classes:
1) try ns::class
2) autoload ns::class
3) fail

Since we can stack autoload we could provide a c-level autoload function
that does the default lookup.

function global_autoload($name) {
 if (($p = strrpos($name, '\\')) !== false) {
   $name = substr($name, $p);
if (__NAMESPACE__ == substr($name, 0, $p -1) && class_exists("\\ $name")) {
     use "\\$name";    // if we find a way to do this at C-levle
   }
 }
}


just to make sure i understand this correctly .. you are suggesting here that we make it somehow possible in __autoload() to fallback to the global namespace. so that if someone wants the fallback to global namespace behavior for classes, he could get this by calling this standard autoload function (or rather by using the spl autoload stack - noting that spl may not be disabled anymore as of PHP 5.3).

more specifically you want to enable use statements inside autoload. i presume that use statement would only be in effect for this single name resolution? as in the use statement would not have an affect on subsequent triggering of autoload, even when originating from the same file?

regards,
Lukas Kahwe Smith
[EMAIL PROTECTED]




--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to