Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rochester!pt!ius2.cs.cmu.edu!edw From: edw@ius2.cs.cmu.edu (Eddie Wyatt) Newsgroups: comp.lang.c Subject: Re: Writing readable code Message-ID: <1221@ius2.cs.cmu.edu> Date: Wed, 1-Jul-87 09:40:29 EDT Article-I.D.: ius2.1221 Posted: Wed Jul 1 09:40:29 1987 Date-Received: Sun, 5-Jul-87 20:30:04 EDT References: <1158@copper.TEK.COM> <6858@auspyr.UUCP> <17171@cca.CCA.COM> <221@amanue.UUCP> Organization: Carnegie-Mellon University, CS/RI Lines: 54 In article <221@amanue.UUCP>, jr@amanue.UUCP (Jim Rosenberg) writes: > while ((c = getchar()) != EOF) { > . > . > . > > It didn't take me long once I was actually using C on a regular basis to > realize that forgoing constructs such as the one above is not only ridiculous, > a case can be made that it is actually LESS CLEAR stylistically. Yes, it is > more difficult to read for novices to C. But consider the alternative: ^^^^^^^^^^^^^^^ > > for (;;) { > c = getchar(); > if (c == EOF) > break; > . > . > . [ lots of stuff about how this is unreadable] > -- > Jim Rosenberg > CIS: 71515,124 decvax!idis! \ > WELL: jer allegra! ---- pitt!amanue!jr > BIX: jrosenberg seismo!cmcl2!cadre! / "the alternative"! Come on there are a thousand and one ways to code the semantics of the above loop. For example : c = getchar(); while (c != EOF) { . . . c = getchar(); } Look, no assignments in the conditionals, no hidden gotos (break). For the people that argue the first form is bad, this would probably be the approach they would take. I still prefer the first form though (the assignment inside the conditional). Its just a matter of style to me, not readablity. -- Eddie Wyatt e-mail: edw@ius2.cs.cmu.edu terrorist, cryptography, DES, drugs, cipher, secret, decode, NSA, CIA, NRO.