Should we deprecate comma?
Asman01
jckj33 at gmail.com
Sun Mar 23 19:54:45 PDT 2014
On Monday, 24 March 2014 at 02:31:46 UTC, Andrei Alexandrescu
wrote:
> 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
I could live with that too but I suggest to extend if(condition)
to allow assignment too:
if(condition) x = 2, y = 3; // fine
if(condition) f(),x=3; // ERRROR
What do you think?
More information about the Digitalmars-d
mailing list