Comma operator = broken design
Jonathan M Davis
jmdavisProg at gmx.com
Fri Dec 9 09:06:00 PST 2011
On Friday, December 09, 2011 13:00:57 Timon Gehr 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'?
>
> > 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.
In my experience, someone like you who uses the comma operator outside of for
loops much at all is incredibly rare. It's far more typical to consider the
comma operator confusing and error-prone than it is to use it frequently.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list