The more I code, the more reasons I find to simply use parentheses everywhere. Why bother even thinking about
1 + 2 * 4
when you could write
1 + (2 * 4)
Ok, if you've got a lot of operators in one line, it can get difficult, but you're probably running into trouble reading it even without parenthesization. It seems like one of the huge wins of Lisp that you don't have to worry about this problem.
Agreed. Whenever I see one of those operator precedence tables in a programming language book, I just skip it. Other than BODMAS, I have no real idea what precendence logical/bitwise operators etc have - I just use parentheses, and always have done.
Like you say - why waste brain cycles trying to parse expressions. But then I also write comments in my code :-)
This brings up an interesting problem for me. I've written a number of compilers where operators were not defined at parse-time, but handled via macros that can be defined at any point. This makes the logic for transforming infix operators very difficult. If a change was made to make all operators operate left-to-right, this issue would go away. What do you guys think about this? Would it cause you serious problems while writing code?
[+] [-] zck|16 years ago|reply
Ok, if you've got a lot of operators in one line, it can get difficult, but you're probably running into trouble reading it even without parenthesization. It seems like one of the huge wins of Lisp that you don't have to worry about this problem.
[+] [-] nomoresecrets|16 years ago|reply
Like you say - why waste brain cycles trying to parse expressions. But then I also write comments in my code :-)
[+] [-] daeken|16 years ago|reply
[+] [-] noss|16 years ago|reply
[+] [-] nopassrecover|16 years ago|reply