On Fri, 17 Feb 2006, Florin Iucha wrote: > On Thu, Feb 16, 2006 at 06:48:04PM -0600, Brian Hurt wrote: >> Of course, pretty much all use of >> the comma operator is abuse of the comma operator. > > The comman operator is used extensively in for loops, to allow two > indices to advance in unison. This is one of those situations where a lot of people think it's an optimization, but it's not. Say you're doing: for (i = 0, j = k; j < n; i++, j++) { a[i] = a[j]; }; On most systems, it's actually *more* efficient to do: for (j = k; j < n; j++) { a[j-k] = a[j]; } Especially if k is a constant, like 1. The few times this is really necessary, hoisting one variable up out of the for loop doesn't hurt performance at all. Therefor, using the comma operator in the a for loop, even for multiple indicies, is an abuse of the comma operator. > > The other use is in silly tricky questions used in interviews to > humiliate the applicants. This isn't an abuse of the comma operator, this is an abuse of interviewees. But it can be quite entertaining to watch. Although personally I perfer tricky questions about sequence points. Brian