DIP19: Remove comma operator from D and provision better syntactic support for tuples
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon Sep 24 08:19:50 PDT 2012
On 9/24/12 4:17 AM, Don Clugston wrote:
> Regarding the comma operator: I'd love to deprecate it, but even if we
> don't, could we at least ensure that this kind of rubbish doesn't compile:
>
> void main()
> {
> int x;
> x > 0, x += 5;
> }
>
> At present, because comma expressions are expressions, not statements,
> the "x > 0" doesn't generate a "statement has no effect" error, despite
> the fact that it is meaningless and gets completely discarded.
Interesting. The comma operator is probably the only one in which an
expression is evaluated only for the sake of its side effects. So
eliminating the comma operator would just get rid of that case by design.
Of course, there's always the option of adding more checks or rewriting
the comma operator from "expr1, expr2, expr3" to "{ expr1; expr2; return
expr3; }()".
Andrei
More information about the Digitalmars-d
mailing list