Should we deprecate comma?
Meta
jared771 at gmail.com
Sun Mar 23 19:45:00 PDT 2014
On Monday, 24 March 2014 at 02:31:46 UTC, Andrei Alexandrescu
wrote:
> One concession we could make would be to disallow using the
> result of the operator. That might actually catch all bugs
> discussed herein.
>
> if (condition) ++i, ++j; // fine
> foreach (e; exp1, exp2) {} // ERROR
> if(pMgr->ShouldRecordEvent(eSE_Weapon), pOwnerRaw) // ERROR
> return pMgr->RecordEvent(eSE_Weapon), pOwnerRaw; // ERROR
>
> I think this would be a compromise worth looking into.
>
>
> Andrei
That's a good idea. I never personally use the comma operator, as
I think that it makes code less readable having multiple
expressions evaluated on a single line. For the same reason, I
almost never put multiple semicolon-delimited statements on the
same line. Code like the above I find particularly egregious. It
plays havoc with the programmer's expectation that they can parse
the code left-to-right to figure out the result of an expression,
forcing them to read in spirals. This is just as bad as the
pointer declaration syntax for C/C++, just not as common.
More information about the Digitalmars-d
mailing list