home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
- From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
- Subject: Re: FORTRAN bug(was Re: C++ vs. Ada -- Is Ada loosing?)
- Message-ID: <9234801.7095@mulga.cs.mu.OZ.AU>
- Sender: news@cs.mu.OZ.AU
- Organization: Computer Science, University of Melbourne, Australia
- References: <EACHUS.92Dec7184734@oddjob.mitre.org> <1992Dec8.072300.21473@smds.com> <1992Dec8.172551.16780@newshost.lanl.gov> <1992Dec9.060218.23940@seas.gwu.edu>
- Date: Sat, 12 Dec 1992 14:20:17 GMT
- Lines: 41
-
- 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!
-