Re: RFC: Dropping Namespace

From: Date: Tue, 04 Dec 2007 23:36:50 +0000
Subject: Re: RFC: Dropping Namespace
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-33699@lists.php.net to get a copy of this message
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

« previous php.internals (#33699) next »