PHP: \ as namespace separator. What were they thinking?
ninh.nl
ninh.nl
PHP 6: "\" is an awesome new feature that makes web development more approachable.
PHP 7: "\" is an awful idea, avoided by the clueful and widely denounced. You can disable it in php.ini, but that's not the default. 80% of practicing developers know none of this.
PHP 8: The php.ini default changes. Gang wars erupt in the shared hosting ghetto. You can force it on or off at the code level, and a comment thread in the PHP manual contains 23 different slightly-broken copy-and-paste snippets.
PHP 9: "\" doesn't exist anymore. Everyone ignores PHP 9 until three weeks before PHP 8 is EOL'd.
It's not that I can't get stuff done with it. It's that it is designed and maintained by people who don't know very much about language design, coupled with the fact that PHP is in position to have some people that are experienced with such things come in and re-do it.
I mean, I'm far from being versed in the ways of writing programming languages, but I can write a parser that can handle one token being used for different things if I need to. I would think that it's a pretty common thing (and is probably in the class of things where you'd rarely be writing one from scratch, but I digress).
Every time I use it, I end up feeling like I'm beating my face against the language. That's not quite accurate - I end up feeling like I'm beating my face against years of poorly thought out design decisions with little to no effort made to remove them.
Perhaps I'm missing out on some things that make this a lot harder for PHP, especially considering that I'm not part of the PHP community (and considering that I avoid it when possible) - but it really seems to me that most of PHPs problems, from a language perspective, are solved problems.
1) is less desirable because unlike C++ PHP is not compiled. I could imagine some random included file that you disabled for testing causing an ambiguity error.
2) could work if you choose a representation that is human readable and easily parsable. The exclamation point seems to fit that description.
true == !false
true == !Foo::bar()
Paamayim Nekudotayim is the best option, you could even use it as a prefix in case of ambiguity: true == ::Foo::bar()to convert stuff to explicit true/false
Not a problem: either the PHP generated is only safe for a particular version, or they can add parenthesis to distinguish the cases.
> to convert stuff to explicit true/false
I suppose. That would seem like a surprising use to me, and would merit an explanatory comment, but given that, it might be better to just explicitly cast ("(bool)$name"), which saves the comment, and only adds four characters over "!!$name".
!(!(true))
! ! true
!!true
Having !! not be the same as ! ! would probably be the first case in PHP of significant whitespace.You shouldn't be using PHP anyway, it's a toy for kids.