Feature request: extending comma operator's functionality

bearophile bearophileHUGS at lycos.com
Thu Oct 4 17:08:14 PDT 2012


Tommi:

> Maybe we forget about commas then, and extend if-clauses so 
> that you can properly define variables at the beginning of it. 
> Separated by semicolons.

Regarding definition of variables in D language constructs, there 
is one situation where sometimes I find D not handy. This code 
can't work:

do {
   const x = ...;
} while (predicate(x));


You need to use:

T x;
do {
   x = ...;
} while (predicate(x));

Bye,
bearophile


More information about the Digitalmars-d mailing list