Xref: utzoo comp.unix.questions:13050 comp.lang.c:17899 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!bucsb!crewman From: crewman@bucsb.UUCP (JJS) Newsgroups: comp.unix.questions,comp.lang.c Subject: Re: comma operator: keep away? Message-ID: <2495@bucsb.UUCP> Date: 25 Apr 89 19:05:21 GMT References: <10007@smoke.BRL.MIL> <498@lakart.UUCP> <10057@smoke.BRL.MIL> <628@gonzo.UUCP> <28831@ucbvax.BERKELEY.EDU> <1989Apr24.172219.817@utzoo.uucp> <28890@ucbvax.BERKELEY.EDU> Reply-To: crewman@bucsb.bu.edu Followup-To: comp.unix.questions Organization: Boston Univ Comp. Sci. Lines: 56 In article <1989Apr24.172219.817@utzoo.uucp> (Henry Spencer) writes: > >On the other hand, a C programmer who [uses a comma operator to sequence >two closely related expression evaluations, instead of two statements] >should ... be investigating alternate career paths, because he's clearly >an amateur in a business that needs professionals. Anyone who says "any >competent programmer ought to be able to understand that!" rather than >"I should make my code as clear as possible!" is an amateur, and one with >an ego problem at that. Readability is very much a matter of what you're >used to. Like it or lump it, most C programmers are used to [the compound >statement] and not [the comma construct]. > I believe that should read, 'most *Pascal* programmers are used to the compound statement and not the comma construct'. This is just my opinion, and one with which many people differ, but why are C programmers always advised not to use the unique features of C? So far, I've been advised against: -- using the comma construct -- using the (a ? b : c) expression -- using an assignment as a function -- using "if (a)" instead of "if (a != 0)" -- using += -= *= /= |= &= ^= -- using << >> <<= >>= -- using complex pointer-integer expressions -- generally complex expressions: map |= (line[k++] = string[j++]); -- writing compact source code etc. I've also been advised to go out of my way to make my C programs look like programs written in another language: #define begin { #define end } #define then /* if (a == 1) then return; */ #define when break; case /* when 'a': foo(); when 'b': bar() */ #define otherwise break; default: /* otherwise baz(); */ etc. Getting back to the poster of the above article, why is the person who likes the comma construct an amateur? Is it because s/he likes a unique feature of C? Or is it really because the above "professional" would get confused reading such code? In a business which so sorely "needs professionals", why are we bending over backwards to make our programs easier to read for ama- teurs? C is designed to be a low-level language. It's advantage over machine language and even higher-level languages is its power derived from its simplicity and compactness. It is in this way an elegant language; as C programmers, we have the tools to make powerful programs compact. Yet we are constantly advised to throw away these tools. I believe that that is VERY unprofessional. I repeat: this is just my opinion so mail flames to me. -- JJS