On PHP Namespace Separator

Posted on 05.11.2008 by Antti Holvikari

There’s been a lot of negative commenting around the choice of the new namespace separator for PHP. The choice was backslash '\'. The usual answer to these comments is: “Pick a better one, and let’s see how that works out” or “please stop commenting, '\' is the only one that works”.

And I understand this. '\' is the only viable choice.

But the thing is, backslash sucks as a namespace separator. You can’t create namespace names with string interpolation because '\n' would then get transformed to a newline. But above all, it’s ugly.

I’d much rather live without namespaces than have a bad (ugly) implementation. I mean, do you really want namespaces this badly?

Also, the old excuse of “you don’t have to use namespaces” completely misses the point that I have to maintain some poor guy’s code someday that has namespaces in it.

blog comments powered by Disqus