in reply to Re^9: Precedence design question...'x' & arith
in thread Precedence design question...'x' & arith
In an expression like:
it is more efficient for the interpreter to do the numeric calculation first as 2*2 is 1 instruction while the other requires buffer allocation for a result. So perl has to do MORE work -- to end up with an expression that fails. If that's not a hint that the precedence rules could use some fine tuning, I don't know hat is.' ' x 2*3
Currently, the operators, 'x', '*', '/' are at the same level. Below them are '.', '+', and '-'.
But having the string operators at the same level as the numeric operators doesn't makes sense. If there is a logic in that choice, please explain it. In mathematics it is generally a given that an simple expression can be simplified by distributing operands and getting rid of parentheses.
'x' doesn't belong in the same group as * and /. One, because it isn't communicative, 2) because technically it's a call to an internal API-function that requires its arguments in a specific order. It's even more rigorous in its requirements than ".".
This is a case of the language breaking the principle of generalization. The only way you can intermix those operators is if all operands are numbers and then you end up with a very specialized usage that isn't intuitive at all.
I'm proposing the idea that in separating the precedence, we make the ability to combine statements composed of numbers and strings a generalized possibility, whereas now, it's a special case in the language -- more so because the 'x' operator isn't commutative.
As for your common on poisoning the well, I am not sure I follow, unless you mean by my persistence, in adherence to ideals I alienate people. That is unfortunate if that is the case.
|
|---|