Path: utzoo!attcan!uunet!ncrlnk!ncr-sd!hp-sdd!hplabs!gatech!ulysses!cjc From: cjc@ulysses.homer.nj.att.com (Chris Calabrese[mav]) Newsgroups: comp.lang.c Subject: Re: Always use braces (was: Suggested new C loop syntax) Summary: tripple ick for bad style on the part of CS profs Message-ID: <11037@ulysses.homer.nj.att.com> Date: 23 Dec 88 17:58:47 GMT References: <5@rsoft.UUCP> <1071@goofy.megatest.UUCP> <861@quintus.UUCP> <271@twwells.uucp> Organization: AT&T Bell Laboratories, Murray Hill Lines: 44 In article <271@twwells.uucp>, bill@twwells.uucp (T. William Wells) writes: > In article <8@estinc.UUCP> fnf@estinc.UUCP (Fred Fish) writes: > ... > : I was recently helping out a freshman CS major with her C homework and > : found out, to my horror, that the teacher in the course was marking > : off points for code which included braces when they weren't strictly > : required. They were teaching her to write code like: > : > : inchar = getchar (); > : while (inchar != EOF) > : if (inchar == 0) > : goto done; > : else > : inchar = getchar (); > : done: return inchar; > : > : Ickkk!!! > > Double Ickkkk!!!! A goto where a break would have done. This is yet another tripple icky example of CS professors thinking that just because they can get the example programs in K&R to compile, and because they did work in Fortran in their thesis on astrophysics, they are qualified to teach C (or any other language). Wrong, wrong, wrong. Any C guru qualified (in my humble opinion) to teach C would be trying to teach code which looks like: /* * assume students have not learned the ',' operator yet */ do { inchar = getchar(); } while(inchar != EOF && inchar); return inchar; Personally, I haven't decided whether the while should be lined with the do or the loop body yet, but I like the brace alignment this way. -- Christopher J. Calabrese AT&T Bell Laboratories att!ulysses!cjc cjc@ulysses.att.com