Should we deprecate comma?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Mar 23 19:31:25 PDT 2014


On 3/23/14, 7:21 PM, Kenji Hara wrote:
> At least I can imagine two reasonable cases.
>
> 1. If the code is ported from C/C++, breaking it is not reasonable.
>
> 2. If the two expressions are strongly related, using comma operator is
> reasonable to represent the intensity. I think rather it's an *ability*
> to represent code meaning by using code style.
>
> Kenji Hara

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



More information about the Digitalmars-d mailing list