Page 1 of 1

Poll: PHP's Latest Namespace Controversy

Posted: Mon Oct 27, 2008 12:22 pm
by volomike
As you may have heard, the core PHP team have made a decision on how to implement the namespace separator. They chose:

\

Re: Poll: PHP's Latest Namespace Controversy

Posted: Mon Oct 27, 2008 1:19 pm
by Christopher
I think :: made the most sense because it followed the current usage of accessing names statically in classes. it is the best conceptual match. I know there were some cases where there was ambiguity, but they are not showstoppers to me -- no different than the current Python implementation.

Honestly, namespaces is a marginally useful feature that seems to be clamored for by a small group of programmers who claim it is the mark of a serious language.

Re: Poll: PHP's Latest Namespace Controversy

Posted: Mon Oct 27, 2008 1:44 pm
by Luke
I disagree that its a marginally useful feature, but I also don't really think PHP needs them. We've been faking them with class prefixes and its worked fine. If you want namespaces, use python. :) That's my opinion anyway.

Re: Poll: PHP's Latest Namespace Controversy

Posted: Mon Oct 27, 2008 3:41 pm
by koen.h
I would have preferred '::' and take the static issue with it.

Re: Poll: PHP's Latest Namespace Controversy

Posted: Mon Oct 27, 2008 3:47 pm
by VladSun
.
Because I've used it with other languages ;)

Re: Poll: PHP's Latest Namespace Controversy

Posted: Mon Oct 27, 2008 4:01 pm
by Christopher
VladSun wrote:.
Because I've used it with other languages ;)
Can't because . is the concatenation operator. Can't switch the concatenation operator to + because variables are typeless. The + converts to numeric, whereas . converts to string.

Re: Poll: PHP's Latest Namespace Controversy

Posted: Mon Oct 27, 2008 4:06 pm
by VladSun
:( 60% votes ;)
Why is it included in the poll then?

Re: Poll: PHP's Latest Namespace Controversy

Posted: Mon Oct 27, 2008 4:38 pm
by Bill H
I'm with the '::' crowd, but I can't really explain. Just my sense of it. Probably senility.

Re: Poll: PHP's Latest Namespace Controversy

Posted: Mon Oct 27, 2008 9:21 pm
by alex.barylski
I would have personally gone with ::: or ::
Honestly, namespaces is a marginally useful feature that seems to be clamored for by a small group of programmers who claim it is the mark of a serious language.
Agreed. Seeing as most PHP frameworks and projects use their own class name prefixes and it's become standard practice...why are namespaces really needed? Honestly I have never used them or needed them in PHP.

Re: Poll: PHP's Latest Namespace Controversy

Posted: Tue Oct 28, 2008 12:25 pm
by crazycoders
:: could have been a good idea, but depending on the compiler structure, it is sometimes not possible and would require too much change

I agree with \ more than the others because \ means "sub" in several contexts. (Networking, filesystems, listing of elements, etc) A namespace\function means a lot and cannot be confused with the :: operator when only the namespace and class is provided. If you see this:

$a = new facebook::user($facebookid);
//What did we intend really here? Create a new user from the facebook namespace? Or use the user function in the facebook class to return the name of a class that is sent to the new operator?

$a = facebook::getUser($facebookid);
//And here? Call the static function getUser from the facebook class? Or call a global function defined in the facebook namespace?

$a = new facebook::getUser($facebookid);
//And here, what are we doing? Creating a getUser object from a facebook namespace? Or did we intend to call the getUser function from the facebook class in a static way? It could have been a typo?

All these would result in logical or hard to spot errors because they are prone to ambiguous results and namespaces are here to prevent ambiguous code constructs.

$a = new facebook\user::getUser($facebookid);
//Much easier to read, you have no doubt here, the user wans to create a new object from the class name returned by the static function getUser from the class user in the facebook namespace... No ambiguities possible.

$a = facebook\getUser($facebookid);
//No doubt here again, we are calling getUser in the facebook namespace... not a static function of a facebook class;

crazyone out

Re: Poll: PHP's Latest Namespace Controversy

Posted: Tue Oct 28, 2008 5:06 pm
by VladSun
arborint wrote:
VladSun wrote:.
Because I've used it with other languages ;)
Can't because . is the concatenation operator. Can't switch the concatenation operator to + because variables are typeless. The + converts to numeric, whereas . converts to string.
In fact, I would have preferred to have strict type variables and operator overloading in PHP instead of having "strict type operators". I would have preferred to have strict mode (as in Perl), so some errors are shown at "compile" (a pseudo one) time.

Re: Poll: PHP's Latest Namespace Controversy

Posted: Tue Oct 28, 2008 8:05 pm
by alex.barylski
In fact, I would have preferred to have strict type variables and operator overloading in PHP instead of having "strict type operators". I would have preferred to have strict mode (as in Perl), so some errors are showed at "compile" (a pseudo one) time.
Absolutely yes... :P