Mix PHP and namespaces, get weirdness


In an interesting decision, the PHP devs have decided to use a backslash, \, as the namespace separator. This is a bit… curious.. choice of a character.

They apparently had a long discussion about their choices, but really, couldn’t they just have used ::, as the manual showed for a while? It’s starting to feel like the fact that PHP was not designed with all these features in mind is starting to show more and more.

The argument that if you used :: as the separator would confuse between static calls is a bit weird, too. Python for example uses . for the namespace separator, method/property access and static method/property access and it works just fine. Now, I don’t know if PHP’s and Python’s internals differ greatly, but they’re both dynamic languages, so at least there shouldn’t be any implementation problems standing in the way for using the same character.

I’ve used languages with definitely weirder syntax than this, but it just seems weird, especially since PHP’s syntax is otherwise so similar to languages like C++. While some people seem to think this will make PHP much worse somehow, I think I’ll eventually get used to seeing the backslash in code, when we actually get 5.3 stable. It just seems really odd now.