2 ms·
So... yeah, I totally agree with the moral of the article. Unless you are actually planning for how to handle a user uprising due to incompatible changes, fix
by ajross 7y ago
So... yeah, I totally agree with the moral of the article. Unless you are actually planning for how to handle a user uprising due to incompatible changes, fix your stuff now. But let's talk about operator precedence instead, because that's more interesting:
The boolean operations are the biggest gotcha, but these are everywhere. Similarly the "*" indirection operator binds more strongly than many programmers think it does (and the same symbol in type expressions too, which is why those parentheses in function pointer declarations that no one really understands are needed). The shift operators got picked up by C++ to do I/O of all things, where get to wreak havoc in a whole new regime.
Frankly the only precedence rules that most programmers understand (because we were taught them in grade school!) is the two-level/left-to-right grammar for the four basic arithmetic operations, along with a vague sense that these should bind more tightly than an operator with "=" in it, because that separates the "other side of the equation".
Given that, why don't new programming languages just require fully parenthesized expressions for expressions involving other operators?
- Ididntdothis 7y ago“Given that, why don't new programming languages just require fully parenthesized expressions for expressions involving other operators?” That would be excellent and be in line with the trend towards “safe” languages. I have countless examples where I read code with several expressions and when I asked the dev if they really understood the situation rules of this language they usually didn’t. They just wrote something they thought should be ok.