Linked by Kaj-de-Vos on Thu 20th Dec 2012 00:22 UTC
Thread beginning with comment 545941
To read all comments associated with this story, please click here.
To read all comments associated with this story, please click here.
My "The C Programming Language, Second Edition" falls open at page 53, where the precedence table of operators is. When I program in C, I often need to refer to it, because it's too complex to remember. Much C code acknowledges that by not even relying on precedence, but littering expressions with parentheses to make them unambiguous.
This problem doesn't exist in REBOL and Red, because they have only two simple precedence rules:
- Operators evaluate from left to right.
- Infix operators take precedence over prefix functions.
If you want * to take precedence over +, you can simply write
1 + (2 * 3)
However, as a REBOL programmer you quickly get used to writing it as
2 * 3 + 1
When I program in C, I often need to refer to it, because it's too complex to remember
So you never learned any of the mnemonics for operator precedence? Or indeed had to learn in in school, or where it is still very much needed in real life?
If you start with the assumption that unary operators come first, and comparison and logical operators come at the end, then the old saw of My Dear Aunt Sally (multiplication, division, addition, subtraction) holds.
Much C code acknowledges that by not even relying on precedence, but littering expressions with parentheses to make them unambiguous
Or like how people do with real math, or have to do in REBOL to make sure the intent is clear?
I am not impresses with this argument. I have met many die hard proponents of Smalltalk, APL, Lisp, and Forth — and with the exception of Forth — none of them have actually claimed that the precedence in their language was somehow better. Instead they would say something like "well the operator precedence is a bit funky, but that is a consequence of how the language works, you will get used to it"
I will end as a general thought: It's ok to admit the flaws of something you love. It isn't somehow admitting defeat. Nothing that is useable in the real world is perfect. Nor in promoting your thing, do you need to talk down something else.





Member since:
2006-07-17
I don't know. A programming language where:
1 + 2 * 3
evaluates to 9 is fail to me.