Hello Lukas,
Wednesday, November 5, 2008, 12:32:19 AM, you wrote:
> 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).
yes
> more specifically you want to enable use statements inside autoload. i
and yes
> presume that use statement would only be in effect for this single
> name resolution?
and yes
> as in the use statement would not have an affect on
> subsequent triggering of autoload, even when originating from the same
> file?
and yes
or in other words give the user the ability to specify when he wants the
fallback to global and not doing a fallback to global per default. That way
we get an efficient lookup witout a double retry:
1) local
2) autoload
3) fail
while the user can stack above in first:
1) local
2.1) autoload as above == global
2.n) autoload
3) fail
and also stack at the end:
1) local
2.n) autoload
2.X) autoload as above == global
3) fail
Best regards,
Marcus
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php