Comma operator = broken design
Timon Gehr
timon.gehr at gmx.ch
Fri Dec 9 04:00:57 PST 2011
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'?
> 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.
> And while it might break code to make the comma operator illegal
> outside of for loops, I would expect that fixing the broken code would
> generally be rather trivial.
Sure.
> The resulting code may not be as compact, but it
> wouldn't be hard to write.
It would be a PITA in some cases.
> 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.
More information about the Digitalmars-d
mailing list