SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    1 Thread(s)

    PHP 5.3 -- Namespace doom of using \

    Anyone here know if the PHP 5.3 dev team is still going to open the can of worms from Hell upon us and use \ as the separation character for name spaces?

    I mean, if they do something that utterly stupid I might actually crack open the books, learn C++ and fork off.

    If :: is a problem what else is there?

    ? is ternary...
    # comments as in perl
    ~ might be possible.

    MyProject~MyModule~Class::method

    Not too bad. I don't think PHP is using tilde for anything now.

    Of course, I don't quite understand why the engine needs two different operators for classes and method separation that differ only when the class is statically invoked.. You know :: and ->

    That said, for the love of all that is holy PLEASE don't use the escape character \

  2. #2
    SitePoint Addict wibble wobble's Avatar
    Join Date
    Dec 2008
    Posts
    242
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looks like it: http://uk.php.net/language.namespaces (see under "Example #1 Namespace syntax example").

    The \ does look pretty stupid IMO. I would much prefer ::, or even a variation of it (like ::: maybe?) if they wont reuse that.

    ~ I *think* is used in some obscure operator.
    Find freelance jobs from all the major sites in one place:
    on twitter / on the web / twitter rss feed

  3. #3
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    1 Thread(s)
    It doesn't just look stupid, it IS stupid. Imagine trying to eval a namespace string dynamically (reasons not to use eval aside for a moment)... The statement under this brain dead scheme would read

    PHP Code:
    eval("$myObject = new MyNamespace\\MyProjectSpace\\MyClass()"); 
    And that's just the tip of the iceberg. \ is the escape character. It should not have any other purpose.

  4. #4
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wibble wobble View Post
    ~ I *think* is used in some obscure operator.
    By 'obscure' you mean the bitwise operators. It is bitwise 'Not'.

  5. #5
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Michael Morris View Post
    It doesn't just look stupid, it IS stupid. Imagine trying to eval a namespace string dynamically (reasons not to use eval aside for a moment)... The statement under this brain dead scheme would read

    PHP Code:
    eval("$myObject = new MyNamespace\\MyProjectSpace\\MyClass()"); 
    And that's just the tip of the iceberg. \ is the escape character. It should not have any other purpose.
    Why not? So you have to escape it if you use eval() (which you shouldn't ever need to do).

    I don't see what is wrong with using \ personally.

  6. #6
    SitePoint Addict wibble wobble's Avatar
    Join Date
    Dec 2008
    Posts
    242
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stormrider View Post
    By 'obscure' you mean the bitwise operators. It is bitwise 'Not'.
    Thats the ones - thanks!
    Find freelance jobs from all the major sites in one place:
    on twitter / on the web / twitter rss feed

  7. #7
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stormrider View Post
    I don't see what is wrong with using \ personally.
    For one thing, every friggin texteditor in the world is going to need an update to get syntax highlighting right. \ is a meta character in every other context.

  8. #8
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ok, mine only highlights it when it is within a string, which is the only context it is a meta character.

  9. #9
    Use The Cloud
    Join Date
    Jan 2006
    Location
    Boise, ID
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Brad Hanson, Web Applications & Scalability Specialist
    ► Is your website outgrowing its current hosting solution?
    ► PM me for a FREE scalability consult!
    ► USA Based: Available by Phone, Skype, AIM, and E-mail.

  10. #10
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    You should of taken part in the discussion that toke place to determine what seperator to use. http://wiki.php.net/_media/rfc/php.ns.txt?id=rfc%3Anamespaceseparator&cache=cache It wasn't something they randomly chose.

    The editors I've tried have had no problems with using "\" of course none of them actually support PHP 5.3 yet. Writing "\\" in a string really isn't so different then "::" is it?
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  11. #11
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stormrider View Post
    Ok, mine only highlights it when it is within a string, which is the only context it is a meta character.
    OK. Admittedly, so does mine. Or rather, it's hard to tell because it doesn't recognise the syntax at all, but that would be true of any separator. Maybe it's just in my mind that it reads wrong.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •