Comma operator = broken design

Regan Heath regan at netmail.co.nz
Fri Dec 9 04:11:56 PST 2011


On Fri, 09 Dec 2011 12:00:57 -0000, Timon Gehr <timon.gehr at gmx.ch> wrote:
> On 12/09/2011 10:26 AM, Jonathan M Davis wrote:
>> On Friday, December 09, 2011 10:19:18 Don wrote:
>>> Are there any cases where you're using comma outside of for loops?
>>> I wonder how much would break if were made illegal everywhere else.
>>
>> I'm sure that it would break code, but most people consider it bad  
>> practice to
>> use the comma operator for much outside of for loops.
>
> 'most people'?

Yes, I would guess that you're in the minority here.

>> Occasionally, it's
>> useful to use one in an expression, but on the whole, it's just  
>> confusing and
>> error-prone.
>
> It is confusing to people who don't know the language. It is a simple  
> construct. In my experience, it is certainly not error prone. If you are  
> aware that such an operator exists.

It's error prone in cases where you use it without realising, as in the  
example I posted.

>> The resulting code may not be as compact, but it
>> wouldn't be hard to write.
>
> It would be a PITA in some cases.

Really?  Give us an example where not having comma makes things  
significantly difficult.

>> And unless you're dealing with a programmer who
>> uses it uncommonly often, not much code is going to break.
>
> I _am_ such a programmer.

So it seems :)  I don't want to make your life harder but I think this  
change would make life easier for a large number of people, a small amount  
of the time.  The equation is unbalanced in favour of it's removal, IMO.

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d mailing list