[Issue 8757] Require parenthesization of ternary operator when compounded
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jan 19 01:28:22 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8757
--- Comment #5 from bearophile_hugs at eml.cc 2013-01-19 01:28:20 PST ---
(In reply to comment #4)
> I don't care if it solves half the bugs involving ternary operators that ever
> happen.
So you are saying that data in language design should be ignored?
> You're suggesting that we force programmers to format their code in a
> particular way, and I object to that.
C language has some design mistakes, like in its precedence rules. A well
designed language, and one of the design principles of D, has to help the
programmer avoid the most common bugs. D fixes some of the mistakes of C
design. This is a "formatting forced by D", that has saved me few times:
void main() {
int x, y;
auto z = x & 1 == y;
}
temp.d(3): Error: 1 == y must be parenthesized when next to operator &
See also issue 5409 for something similar.
You don't want to many parentheses in expressions, but few strategically placed
ones are a small price to pay to save you code from common mistakes.
Your words don't hold water, unless you show that adding a ( ) there harms
readability or some other real coding quality.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list