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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php