Slashdot Mirror


PHP Gets Namespace Separators, With a Twist

jeevesbond writes "PHP is finally getting support for namespaces. However, after a couple hours of conversation, the developers picked '\' as the separator, instead of the more popular '::'. Fredrik Holmström points out some problems with this approach. The criteria for selection were ease of typing and parsing, how hard it was to make a typo, IDE compatibility, and the number of characters."

5 of 523 comments (clear)

  1. yet another wtf by larry+bagina · · Score: 3, Interesting

    The rfc claims that typing "**" is easier than typing "%%" or "^^".

    --
    Do you even lift?

    These aren't the 'roids you're looking for.

  2. Re:WTF? by ThePhilips · · Score: 4, Interesting

    You should say "thanks" they haven't chosen something else. e.g Jam (build system; make analog) uses "!" as a "platform neutral" path separator. During evaluations for new build system I joked that I oppose jam since we do not need a "platform neutral" system - we need one for *nix and cygwin. To my surprise many supported me.

    I think their decision to use '\' is very very dumb one.

    I'm still huge fan of Objective-C in that aspect. Unlike C++, which tried to marry C and objects, ObjC took more pragmatic approach: C constructs remains C constructs and object oriented constructs got new distinctive syntax so that you can never mix up what code you are looking at.

    In that aspect, I think PHP folks would regret their decision in future: '\' isn't distinctive enough and they would need to introduce more silly syntax hacks when extending language further.

    --
    All hope abandon ye who enter here.
  3. Re:Today is a Wonderful Day by siride · · Score: 3, Interesting

    Perl once used "'" to separate package name parts. Still does for backwards compatibility. Really annoying. Oops! I love Perl, btw.

  4. Other suggestions by lepidosteus · · Score: 3, Interesting

    For additionnal fun, read this: http://wiki.php.net/rfc/namespaceseparator

    Looks like they considered stuff like :> and :) as separators for namespace. Seriously.
    Also, they don't give any malus for tybe-ability to \ while on most european keyboards it's a lot harder than any other suggested separator. Way to go !

  5. Wonderful analogy! by MarkusQ · · Score: 3, Interesting

    GOTO is what your CPU is actually doing 80% of the time.

    And your car's engine spends all of its time repeatedly causing small explosions with volatile petroleum.

    The driver is generally recommended to let the engine do this and not try to intervene or do it themselves.

    Spot on. Dead on target and a car analogy. You rock.

    --MarkusQ