Namespace Changes Separator Again

Namespace Changes Separator Again

In a bid to include the much touted namespaces has once again changed so the the separator is not longer the double colon (::) and will now use the backslash (\) as a separator.

The previous double colon that would over ride the static calling of class properties if used inside a namespace declaration was problematic and some measure of sanity was needed to resolve this. Namespace loop's were also problematic and would require up to four hash table look ups for every static call. This was not an ideal solution and a way forward was needed.

By implementing the backslash character as a separator, the ambiguity inherent with the double colon between static class methods/constants, and namespace functions/constants is resolved. This will also avoid name resolution order differences and gotchas of foo::bar() in a namespace and in global code.

While the double colon method was always set to cause some issues of readability, due to conflicting syntax with static calls, the backslash method eliminates this and provides for more readable code. On most US style keyboards this requires less typing with only a single key as opposed to three for the double colon.

While many developers are familiar with file system paths, the backslash provides a syntactic comfort zone that should be familiar, especially those who develop on windows, and deploy on UNIX. However, the backslash is often mistaken for a forward slash in the back of the minds of UNIX developers.

Problems arise for UNIX developers as they lazily apply a "slash". This might take some getting used to, but is not a great deal. However, the backslash is used for escaping, and sometimes multiple backslashes are required to escape the escaping characters. With those small issues, the use of the backslash provides much less issues than the double colon, or even the rejected triple colon (:::).

Although the vote for using the backslash was not unanimous, the ney-sayers have graciously accepted the new syntax and a way forward for inclusion in PHP 5.3 is set, and also stifles the need for a possible PHP 5.4 release in the future, which will free up developers for work on the coming PHP 6.