Originally Posted by
C-UL8R
Hi everyone,
I recently discovered the comma operator in C and it has certainly been useful in my projects. However, I worry that evaluating many instructions in one line can quickly uglify the code and potentially make it harder to read. Are there any generally accepted guidelines about what constitutes abuse of the comma operator and when it is okay/not okay to employ it?
The comma operator is sometimes seen in for loops where you have two index variables
Code:
for (i=0; j = N-1; i < N; i++,j--)
However even here many people frown on its use. Comma operators make code hard to read and seldom have a logical purpose, and most people avoid them. I do know of one programmer who disagrees with this and uses them heavily, but he is very much the exception.