On 7/23/07, Brian Moon <[EMAIL PROTECTED]> wrote:
David Zülke wrote:
> Oh yes, sure, that must be the main point about namespaces - I can use
> "::" instead of "_" as a delimiter! Yay!

If all you are going to do is:

<?php

include "MyClass.php";
import MyClass;

?>

Then why use a namespace?  I really don't see the point.  Namespaces are
doing nothing for you in this case.

It is not always in your power to decide if you need namespace or not.
If you use
some lib from Vendor1 there's a good chance that all lib is in Vendor1 namespace
you want it or not.

If you use that Vendor1 lib in one.php file a lot you clutter your code with
Vendor1::A, Vendor1::B, Vendor1::C, etc. It is possible to rename Vendor1
to something shorter using import but you still have to prefix it.

Now as import has effect only in file where it was used it would be nice to
import all names from Vendor1 to the file one.php where it is heavy used and
not to the ones that include one.php.

So if the second.php file includes one.php global namespace is not
cluttered with
names from Vendor1 namespace. Only with names from one.php (if its names are
not in some namespace by them selves.) This way second.php may include&import
some lib from Vendor2 to accomplish its tasks without even worrying about libs
used in one.php.

That's why people sometimes want to import *all* names from namespace.


Regards,
Giedrius

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

Reply via email to