From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1d321b3a6b8bcab2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-01-24 06:36:04 PST Path: pad-thai.cam.ov.com!bloom-beacon.mit.edu!panix!news.mathworks.com!udel!gatech!swrinde!news.uh.edu!uuneo.neosoft.com!Starbase.NeoSoft.COM!not-for-mail From: smize@Starbase.NeoSoft.COM (Samuel Mize) Newsgroups: comp.lang.ada Subject: Re: "Subtract C, add Ada" Date: 24 Jan 1995 08:25:54 -0600 Organization: NeoSoft Internet Services +1 713 684 5969 Message-ID: <3g32li$5jd@Starbase.NeoSoft.COM> References: <3fo2ot$su2@miranda.gmrc.gecm.com> <1995Jan23.154631.6702@sei.cmu.edu> NNTP-Posting-Host: starbase.neosoft.com Date: 1995-01-24T08:25:54-06:00 List-Id: In article <1995Jan23.154631.6702@sei.cmu.edu>, Robert Firth wrote: >In article <3fo2ot$su2@miranda.gmrc.gecm.com> bill@valiant (R.A.L Williams) writes: > ... >> 1. It allows your code to be more compact. > >> NB DONT confuse compactness with poor layout! I find that, for example: >> >> while ((c = getchar()) == ' ') >> { >> /* count spaces */ >> } >> >> is clearer than the 'expanded' alternative (to *me* :-). > >Nope, I find this totally unclear. Who's counting? Unless I've missed >an invisible declaration, initialisation, and increment, the above >code *doesn't* count spaces, it skips them. I think he intended the comment to represent elided code. .. [good point about explicit exit condition not repeated] >Note also that if there are *no more* non space characters, the C code >dies in an infinite loop, while the Ada code automatically does the >right thing, namely raises the END_ERROR exception. Well "of course" we're assuming that there is no programmer error, this is C! ;-) This bit of code is based on the assumption that there is a null at the end of your string -- oh, but this is a file read. C guys: does C return a null if you getchar at EOF? Or is this a misplaced array idiom? Of course, we *never* see strings without nulls in C... Sam Mize - smize@starbase.neosoft.com