Poll: PHP's Latest Namespace Controversy

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply

Do you think the core PHP team made a colossal mistake with the new \ namespace separator?

Yes - Would have preferred /
0
No votes
Yes - Would have preferred :::
1
6%
Yes - Would have preferred >>
2
11%
Yes - Would have preferred :
1
6%
Yes - Would have preferred . (without spaces before and after)
3
17%
Yes - Would have preferred @
0
No votes
Yes - Would have preferred some other character
4
22%
No
2
11%
Maybe
3
17%
Undecided
2
11%
 
Total votes: 18

User avatar
volomike
Forum Regular
Posts: 633
Joined: Wed Jan 16, 2008 9:04 am
Location: Myrtle Beach, South Carolina, USA

Poll: PHP's Latest Namespace Controversy

Post by volomike »

As you may have heard, the core PHP team have made a decision on how to implement the namespace separator. They chose:

\
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Poll: PHP's Latest Namespace Controversy

Post 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.
(#10850)
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Re: Poll: PHP's Latest Namespace Controversy

Post 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.
koen.h
Forum Contributor
Posts: 268
Joined: Sat May 03, 2008 8:43 am

Re: Poll: PHP's Latest Namespace Controversy

Post by koen.h »

I would have preferred '::' and take the static issue with it.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Poll: PHP's Latest Namespace Controversy

Post by VladSun »

.
Because I've used it with other languages ;)
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Poll: PHP's Latest Namespace Controversy

Post 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.
(#10850)
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Poll: PHP's Latest Namespace Controversy

Post by VladSun »

:( 60% votes ;)
Why is it included in the poll then?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Re: Poll: PHP's Latest Namespace Controversy

Post by Bill H »

I'm with the '::' crowd, but I can't really explain. Just my sense of it. Probably senility.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Poll: PHP's Latest Namespace Controversy

Post 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.
crazycoders
Forum Contributor
Posts: 260
Joined: Tue Oct 28, 2008 7:48 am
Location: Montreal, Qc, Canada

Re: Poll: PHP's Latest Namespace Controversy

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Poll: PHP's Latest Namespace Controversy

Post 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.
Last edited by VladSun on Tue Oct 28, 2008 8:40 pm, edited 1 time in total.
There are 10 types of people in this world, those who understand binary and those who don't
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Poll: PHP's Latest Namespace Controversy

Post 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
Post Reply