From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=BAYES_00,FROM_ADDR_WS autolearn=no autolearn_force=no version=3.4.5-pre1 Date: 12 Dec 92 14:20:17 GMT From: munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh@uunet.uu.net (Fergus Jam es HENDERSON) Subject: Re: FORTRAN bug(was Re: C++ vs. Ada -- Is Ada loosing?) Message-ID: <9234801.7095@mulga.cs.mu.OZ.AU> List-Id: mfeldman@seas.gwu.edu (Michael Feldman) writes: >You make a good point. Perhaps the modern equivalent of that Fortran >single-keystroke bug is my favorite bit of C code (and no, I don't >want to bash C, just point out how common these flukes are): > > int x; > ... > x = 1; > while (x <= 10); > { > printf("%d\n", x); > x++; > } A good compiler would give a warning that the call to printf was unreachable code. The only compiler I have available, gcc, unfortunately doesn't give any such warning. But the Pascal-subset compiler I wrote (as one of the projects for a 3rd-year subject) gives the following warnings for the equivalent Pascal code: warning: variable 'x' is not used after assignment, so assignment has no effect warning: 'while' statement will cause an infinite loop >Any similar idiosyncracies in Ada? The difference between '<' and '>' is only a single keystroke. More insidious perhaps is the difference between '<' and '<='. So it can happen even in Ada. However I do agree that Ada syntax is less error-prone than C or Fortran. This is not because it is verbose but rather because the Ada designers took this issue into careful consideration. I believe that it would be quite possible to design a syntax that was concise but that was no more error-prone than Ada. -- Fergus Henderson fjh@munta.cs.mu.OZ.AU This .signature virus is a self-referential statement that is true - but you will only be able to consistently believe it if you copy it to your own .signature file!