Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!bobmon From: bobmon@iuvax.cs.indiana.edu (RAMontante) Newsgroups: comp.lang.c Subject: Re: comma operator: keep away? Message-ID: <19926@iuvax.cs.indiana.edu> Date: 22 Apr 89 18:49:56 GMT References: <19913@iuvax.cs.indiana.edu> <10092@smoke.BRL.MIL> Reply-To: bobmon@iuvax.cs.indiana.edu (RAMontante) Organization: malkaryotic Lines: 23 gwyn@brl.arpa (Doug Gwyn) <10092@smoke.BRL.MIL> : - [ me ] ->Is there a circumstance in which the comma operator is required, where ->the compound statement cannot be broken into multiple statements? - -You've got to be kidding -- a comma expression is an expression, -whereas multiple statements are not an expression. Thus the comma -operator is useful in contexts where semicolon-terminated statements -would not be. Look at the definition of putc() in most implementations -of for an example. "You've got to be kidding?" In fact someone else suggested getchar() as an example. Looking at the Turbo C stdio.h, and the ULTRIX v1.7 stdio.h, I find that neither one uses a comma in getc, getchar, putc, putchar, or anywhere else, except to separate parameters. Nonetheless I think I get the idea, but that doesn't mean that the code wouldn't work without the comma (does it?) -- couldn't the same semantics be reproduced by a series of statements culminating in the final expression of the parentheses (presumably for assignment purposes)? I said "required", not "useful".