comma operator causes hard to spot bugs

Alex Rønne Petersen xtzgzorex at gmail.com
Mon Apr 23 06:11:03 PDT 2012


On 23-04-2012 11:38, CTFE-4-the-win wrote:
> On Monday, 23 April 2012 at 08:08:52 UTC, Timon Gehr wrote:
>> On 04/23/2012 01:56 AM, deadalnix wrote:
>>> Le 21/04/2012 18:54, bearophile a écrit :
>>>> Jonathan M Davis:
>>>>
>>>>> There have been discussions about the comma operator before. I don't
>>>>> expect that it's going anywhere,
>>>>
>>>> Maybe there are intermediate solutions between keeping wild commas in D
>>>> and disallowing them fully. I think most of my bugs caused by commas
>>>> are
>>>> similar to the one shown by the OP. This means this is not a common
>>>> source of bugs:
>>>>
>>>> foo(), bar();
>>>>
>>>
>>> This is completely redundant with foo(); bar();
>>
>> Not completely, you also need { }
>>
>> if(qux()) foo(), bar();
>>
>>>
>>> I see no benefit from being able to do this.
>
> I think the most common use-case for the , operator is in the "increment
> part" of for loops... but this could of course be special-cased to still
> be allowed...
>

Which is what the rest of the world's programming languages (other than 
C and C++) do.

-- 
- Alex


More information about the Digitalmars-d mailing list