Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!homxb!mhuxt!mhuxm!mhuxo!ulysses!allegra!mit-eddie!rutgers!ames!hc!hi!kurt From: kurt@hi.UUCP Newsgroups: comp.lang.c Subject: Re: comma operator Message-ID: <22902@hi.unm.edu> Date: 16 Jan 88 23:23:40 GMT References: <3819@sigi.Colorado.EDU> <8599@ism780c.UUCP> <1866@bsu-cs.UUCP> Reply-To: zeilenga@hc.dspo.gov (Kurt Zeilenga) Organization: U. of New Mexico, Albuquerque Lines: 39 In article <1866@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes: >I respectfully suggest that the comma operator be used only where it is >essential, and not for convenience. > >Why? Because of the following strange situation. The comma operator >is one of the features of C that is used only rarely, the only common >usages being in for loop expressions and in macros. For this reason I commonly use the comma operator in many other "peculiar" places (in expression by passed to functions, loops, if statements, etc.) because of convenience or need. If C didn't have these convenieces, I would us another language. >compiler writers may not test it as exhaustively as they might, for >example, test assignments or arithmetic operators. The comma operator is as important as any other operator in C. Should we restrict the use of "=" because compiler writers may not test it exhaustively. It is the compilers writers job to implement the language to spec (K&R, ANSI, or whatever). If they can't handle it, then they should find a new job. >So it is more likely that your code will break because of a >compiler bug if you use comma operators in peculiar situations. Any peculiar situation is more likely to bring out a compiler bug. But suggesting programmers use less convenent operators is not the solution. What is the solution? Better compilers (and compiler writers :-). >I base this statistical conclusion on just one line of C code that I >wrote, that annoyed several C compilers on different flavors of UNIX. >-- >Rahul Dhesi UUCP: !{iuvax,pur-ee,uunet}!bsu-cs!dhesi I base my conclusions on absolutely no statistics, just common sense. -- Kurt (zeilenga@hc.dspo.gov)