A question of style

Mark H. Colburn mark at jhereg.Minnetech.MN.ORG
Sat Dec 2 01:56:17 AEST 1989


In article <1989Nov30.001947.14883 at aqdata.uucp> sullivan at aqdata.uucp (Michael T. Sullivan) writes:
>From article <547 at mars.Morgan.COM>, by amull at Morgan.COM (Andrew P. Mullhaupt):
>> 
>> ...I can't think of what I would call a 'proper' use of the comma operator...
>
>while (c = getchar(), c != EOF)
>{
>	...
>}
>
>I posted this instead of mailing it to see what, if any, reaction it got.
>I'm always interested in coding style.

I agree with Henry.  There are few "proper" uses of a comma operator.
The comma operator, since it is vastly underused tends to confuse most
programmer, even competent ones.  Besides, there are more intuitive ways to
write most code which would require a comma.

The code above could be written as 

	while (c = getchar && c  != EOF) { 
	    ... 
	}

Which most programmers would find "more intuitive" than the comma seperated
one.


-- 
Mark H. Colburn                       mark at Minnetech.MN.ORG
Open Systems Architects, Inc.



More information about the Comp.lang.c mailing list