Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Sunday October 26, 2008
04:18 AM

PHPs Namespace Separator

[ #37744 ]

Many of you have already heard the PHP news. The rest of you may have wondered what that strange sound was. That was the sound of tens of thousands of developer's jaws dropping all at once. You see, PHP is getting namespaces and the delimiter is the backslash. Yup. The backslash: '\' (minus the quotes, obviously).

Apparently they were all set to go with the double-colon '::' separator when someone pointed out that this is what they use to call a static class function in PHP:


Uh oh. Now what do you do? Is "BloodyToys" a class or a namespace? In the Perl world, this might seem like a non-issue because unlike many other languages, we don't make a distinction between classes or namespaces. PHP does and this makes parsing problematic. I suppose that PHP could have simply died at compile-time if they found an ambiguous declaration (e.g., a giggle function defined in both a BloodyToys namespace and a BloodyToys class), but the developers decided not to do this and frankly, I have no idea why.

For more on this, I one PHP developer's comments on the new namespace decision. It will be interesting to see what comes of this.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • They can't check reliably check at compile time - because they might not know - but you'd have thought they could check at runtime.

    <rumour mode="joke">I heard that Microsoft bunged them a load of cash to make PHP namespaces look like Windows paths...</rumour>

  • Don't forget that Perl originally used (and still supports) the apostrophe as a namespace separator!

    The old package delimiter was a single quote, but double colon is now the preferred delimiter, in part because it's more readable to humans, and in part because it's more readable to emacs macros. — perlmod []