comma operator causes hard to spot bugs

Timon Gehr timon.gehr at gmx.ch
Mon Apr 23 23:44:36 PDT 2012


On 04/24/2012 03:21 AM, Martin Nowak wrote:
>> if(r.front == 'a' && (r.popFront(), r.front) == 'b') { ... }
>>
>> There are a few similar usages in Phobos. If comma was to be used as a
>> tuple constructor instead, those could be replaced by ( , )[$-1].
>
> Tuples with void elements?

Yes. They behave similar to void.

> And if the first exp had a value one wouldn't like to pay for the copying.

How would this require copying? D language tuples already work in a way 
that would make (,)[$-1] completely equivalent to what (,) does now.


More information about the Digitalmars-d mailing list