-----Ursprüngliche Nachricht-----
Von: Jani Taskinen [mailto:sniper@iki.fi]
We could start with making it an E_ERR..erm..E_STRICT notice if you use {} with arrays or [] with strings. And really separate them in PHP 6. But does it make any sense?
At least some people here would appreciate it :)
This would be consistent with what has been advised in the past, and making [] on strings an E_STRICT
is the logical step after deprecating it as of PHP4 and before disallowing it in PHP6.
Maybe there's more code out there incorrectly using [] on strings rather than using {}, but that doesn't make it more right. And nobody would complain about an E_STRICT.
Removing {} is ultimately the right thing to do, whatever the anti-purists may think.
That is, purism is to have as little different language elements as possible at the cost of overloading? At least I agree that [] and {} being the same is not pure.
"{$str{1}}" vs. "{$str[1]}", you decide..
Admittedly this is ugly to read but the same thing on the other side is $var[$x][$y] vs. $var[$x]{$y}.
Just as checking if there's more code out there using $x[1] or $x{1}, you could check if {} is used more in string contexts or in standalone expressions (not seriously).
-mp.
Oh, btw: http://en.wikipedia.org/wiki/Linguistic_purism: "Linguistic purism is the opposition to any changes of a given language, or the desire to undo some changes the language has undergone in the past." So what do the anti-purists want here? "Anti-purism: A puristic reaction to a manifestation of purism, directed at the removal of neologisms originating from a puristic intervention."
Admittedly this is ugly to read but the same thing on the other side is
$var[$x][$y] vs. $var[$x]{$y}.
True. But having two purposes for {} is not good either.
And most of the time it's up to the coders how they use the existing
features..so this is all pointless. :)
Oh, btw: http://en.wikipedia.org/wiki/Linguistic_purism: "Linguistic
purism is the opposition to any changes of a given language, or the desire
to undo some changes the language has undergone in the past." So what do
the anti-purists want here? "Anti-purism: A puristic reaction to a
manifestation of purism, directed at the removal of neologisms originating
from a puristic intervention."
Damn wikipedia. :)
--Jani
Actually, three: code blocks, interpolation of complex variables, and
string indexing.
- Andrei
True. But having two purposes for {} is not good either.