Less commas

Caligo iteronvexor at gmail.com
Fri Dec 31 02:08:01 PST 2010


On Fri, Dec 31, 2010 at 2:09 AM, bearophile <bearophileHUGS at lycos.com>wrote:

> I'd like to restrict a bit the usage of the comma operator in D2,
> disallowing at compile-time some currently usages that some C style guides
> already suggest to avoid.
>
> If I see production code like the two examples below in production code, I
> change the code, and remove the commas. I think they are confusing, and may
> hide bugs. Do you know other situations where you like to disallow the comma
> operator in D2? Later I will probably write an enhancement request on this.
>
> ----------------
>
> Is x the result of foo() or bar()?
>
> int foo() { return 10; }
> int bar() { return 20; }
> void main() {
>    int x;
>    x = foo(), bar();
> }
>
> ----------------
>
> The comma could be mistaken for a semicolon:
>
> void main() {
>    int x;
>    if (x > 0) x = 0,
>               x = 1;
> }
>
> Bye,
> bearophile
>

What font are you using?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20101231/57731e1f/attachment.html>


More information about the Digitalmars-d mailing list