http://d.puremagic.com/issues/show_bug.cgi?id=11410
Summary: Support equality operator chaining Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: bearophile_h...@eml.cc --- Comment #0 from bearophile_h...@eml.cc 2013-11-01 07:35:12 PDT --- This is valid C code: int main() { int x = 3; int y = 4; int z = 5; int b = x < y < z; return 0; } Bug GCC tells us that code doesn't work as expected by a Python programmer: test.c:5:15: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses] int b = x < y < z; So D disallows that code: test.d(5): Error: semicolon expected, not '<' test.d(5): Error: found '<' instead of statement - - - - - - - - - - - - - - GCC accepts this code: int main() { int x = 4; int y = 4; int z = 4; int b = x == y == z; return 0; } With a warning: test.c:5:15: warning: suggest parentheses around comparison in operand of '==' [-Wparentheses] int b = x == y == z; While DMD refuses that code: test.d(5): Error: semicolon expected, not '==' test.d(5): Error: found '==' instead of statement >From my experience with D code I know there several situations where the chained equality is handy: if (n == foo(n) == bar(n) && ... It avoids code like: aux = foo(n); if (n == aux && aux == bar(n) && ... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------