On 11.07.2008, at 23:17, Greg Beaver wrote:

Stanislav Malyshev wrote:
Hi!

This fixes the logic problem, and re-introduces the performance slowdown for internal classes. FORTUNATELY there is a simple solution to this, which is to "use" all global classes:

The thing is since it'd work without "use", most users would do it that way and have horrible code. But if you can do use ::Exception, you can the same way do use Foo::Exception, right? So what's the difference?

The difference is in what you quoted - name resolution is non- deterministic with current implementation. The suggested change always works the same way. It turns out my internet access is even worse than I thought, so I may only be reading/replying once every week to two weeks until August, please bear with me :/

In other words, with the current implementation, you can just do "use Foo::Exception;" and it works, but if you *forget* to do the use statement, you can get unpredictable behavior with no warning until your code starts not working properly. With the suggested change of name resolution, your code always works as you designed it, but if you forget to "use ::Exception", then your code is simply slightly slower (1 extra call to autoload if it exists), but still works properly. It also tilts the "use" towards internal classnames, which in my experience tend to be outnumbered by userspace classnames, so it will reduce code size, making it more readable.


Greg's argument seems sound to me. With the proposed change errors are less likely and more transparent in case they happen (for people using autoload that is). At the same time people who care about performance can still work around this behavior (then again those that care about optimizations on this level probably do not use autload to begin with).

So I guess the point is .. autoload is there for convinience, so lets make it as convinient as possible.

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