Derick Rethans wrote:
> With all the above considerations, especially my first point, I still have not
> heard any good reason why namespaces in the current implementation are
> actually
> useful - or what particular case they solve... so I am wondering, are they
> really useful? I come now to the conclusion that they are not, and for myself
> (and most likely my work projects) I would have to decide not to go with
> namespaces, but instead stick with the 3 letter prefixing. Something that I
> have totally no problem with, as it is nice and easy.
I have to agree with all points except for the usefulness of "use" - the
ability to re-alias classes is very nice.
Incidentally, one argument - that you can't alias internal classes - is
incorrect. Try this script:
<?php
namespace test;
use xmlreader as test;
class xmlreader {}
?>
However, in the global scope (no namespace) it would fail. This is a
bug that is easily fixed. use should allow re-aliasing of global
classes, and I could provide a very easy fix.
What if we simply kept the ability to alias classes via "use"? The best
feature of the current namespace implementation is the ability to rename
classes in a script. This way, you could use conflicting class names,
as in this example:
file1.php:
<?php
class DB {}
?>
file2.php:
<?php
import DB as Other_DB;
include 'file1.php';
class DB extends Other_DB {}
?>
All the benefits of namespaces with none of the brackets or no brackets
debate.
Greg
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php