Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: `if (a = b)' (was Standard indentation?) Message-ID: <861@quintus.UUCP> Date: 14 Dec 88 02:48:48 GMT References: <5@rsoft.UUCP> <1071@goofy.megatest.UUCP> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 20 In article <1071@goofy.megatest.UUCP> djones@megatest.UUCP (Dave Jones) writes: >{ int ch; > while( (ch = getchar()) != EOF ) > process(ch); >} > >This says it almost literally, "While I get a ch that is not >a sentinal, I want to continue processing." I very much like embedded assignments, but that's a poor argument. To exit a loop when you find a sentinel (that's two Es, no As), you can do /* C version */ -- ADA version for (;;) { loop ch = getchar(); get(ch); if (ch == EOF) break; exit when ch = sentinel; process(ch); process(ch); } end loop I use the "while" version as an idiom for reading from a stream, but it isn't as general a method as the use of 'break'.