Should we deprecate comma?

monarch_dodra monarchdodra at gmail.com
Mon Mar 24 02:35:38 PDT 2014


On Monday, 24 March 2014 at 09:13:39 UTC, ponce wrote:
> On Monday, 24 March 2014 at 09:09:30 UTC, monarch_dodra wrote:
>> //----
>> for (size_t i, j ; someCondition() ; ++i, ++j )
>> {...}
>> //----
>>
>> I think this is *the* single most common use of operator 
>> comma, and I also think it is perfectly legit. Sure, it can 
>> easily be migrated away from, but I think it would be 
>> gratuitous breakage of good code.
>
> Legit but largely useless.
> In every cases I've seen where this idiom appears, you can 
> derive j from i and the compiler is able to generate the very 
> same code.

I've seen plenty of cases where you can't, such as most 
algorithms that "copy filter" or "copy remove". Further, 
especially with ranges, you can't derive one from the other. The 
code usually becomes:

for ( ; someCondition() ; r1.popFront(), r2.popFront() )


More information about the Digitalmars-d mailing list