Lukas Kahwe Smith wrote:
>
> On 16.10.2008, at 18:59, Greg Beaver wrote:
>
>> Lukas Kahwe Smith wrote:
>>>
>>> On 16.10.2008, at 17:37, Stanislav Malyshev wrote:
>>>
>>>> B. There's a huge problem with this proposal which you seem
>>>> consistently to ignore despite all my attempts to explain it. Failed
>>>> autoload on each call is BAD. Very bad. It is not cacheable, it leads
>>>> to multiple disk accesses and it is absolutely undetectable to the
>>>> PHP user without the use of special tools. So making all existing
>>>> code contain this performance bomb unless you rewrite it is very bad.
>>>> It's better to have this code fail and provide simple script to fix
>>>> it in automatic fashion. The fix you propose - writing use's - is not
>>>> enough because as you noted later inertia would make users not to use
>>>> this code and thus have huge performance hit - which most of them
>>>> even wouldn't know where it came from.
>>>
>>> first up i am a bit irritated by the use of the term "internal class",
>>> i guess you both mean to say "class in the global namespaces"?
>> no, we are talking about classes built into PHP such as Exception or
>> ArrayObject, not userspace classes without namespace.
>
> why are they different?
> also since they apparently are different, how does this all work when
> its not about an internal class, but a global useland class? as in
> what if in your example it would not be the Exception class, but a
> class called FooBar, which is defined in the global namespace in some
> userland code? 

That's a great question, and I didn't realize it was a confusion, so
I'll try to answer it clearly.

The purpose behind resolution rules in namespaces is to make it easiest
to access

1) stuff with the same namespace prefix
2) internal functions, constants, and classes built into PHP

So, there is no chance for conflict with this code:

foo.php:
<?php
function __autoload($class){include $class . '.php';}
class Foobar{}
?>

<?php
namespace bar;
include 'foo.php';
$a = new Foobar; // this tries to autoload bar::Foobar if internal class
Foobar does not exist
?>

To force resolution to userspace Foobar, all you need add is:

<?php
use ::Foobar;
?>

Greg

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

Reply via email to