Am 11.12.2007 um 21:22 schrieb Stanislav Malyshev:

Ah. Yes, that makes perfect sense to me. The logical solution must be then, however, not to implement namespaces at all, or requiring code

It's not a solution, it's refusing to solve a problem.

Well, if your answer is that it makes sense this way and that it's not gonna be changed because it cannot be implemented without significant overhead, then I need to say that it would be better to have no namespaces rather than significantly flawed namespaces.


for the behavior from an implementational standpoint, but I think it really is obvious that such a namespace solution would be completely useless, as it would not be possible under any circumstances to provide

If it's "obvious" for you that namespaces are useless, probably you need to give your obviousness-meter a check-up. They were found useful by many people, even if there are things to work out here and there - which happens with each new concept not tested in the field.

They are not useless. They would just be useless


Or, as an alternative, introduce an optional third argument to spl_autoload_register where people can give a namespace name for which the autoloading should be performed. That would cut down overhead since

There's no such thing as "namespace name for which autoloding is performed". Autoloader receives a full class name, that's it. How this name was created is irrelevant.

just the autoload functions of currently imported namespaces would have to be called.

I don't understand what do you mean here, but it doesn't matter, since autoload call on each class access is very bad regardless of how it's implemented internally.

Yes, because you didn't bother to even read what I wrote. I'll explain it with an example for you, maybe that helps:

Let's assume we have ten autoloaders. We are, by import, in namespace Name::Space. Someone does new DateTime();

You would now have to go through all ten autoloaders before you can decide that no userspace class DateTime exists in any namespace, and thus the PHP internal class DateTime may be used.

However, if it were possible to do this:

spl_autoload_register(array('Name::Space::Ship', 'autoload'), 'Name::Space');

Then you could would not have to call ten autoloaders, but just those registered for the currently imported namespaces. As we've only imported "Name::Space", this is just the one I showed above. Class not found? Okay, use PHP's DateTime. Overhead gone.


I don't really think, though, that doing something like use __php__; is a tall order, is it? It would only be necessary for those that consume

"use whatever;" is a no-op. There's even warning about it in the engine.

Stas, really, stop retreating to technical details and making me look like a fool when you're tired of coming up with arguments. You very well know I meant "import". Reply to the suggestion in a respectful manner, or give it a miss.

David

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

Reply via email to