home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / ada / 3634 < prev    next >
Encoding:
Text File  |  1992-12-12  |  2.1 KB  |  53 lines

  1. Newsgroups: comp.lang.ada
  2. Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
  3. From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
  4. Subject: Re: FORTRAN bug(was Re: C++ vs. Ada -- Is Ada loosing?)
  5. Message-ID: <9234801.7095@mulga.cs.mu.OZ.AU>
  6. Sender: news@cs.mu.OZ.AU
  7. Organization: Computer Science, University of Melbourne, Australia
  8. References: <EACHUS.92Dec7184734@oddjob.mitre.org> <1992Dec8.072300.21473@smds.com> <1992Dec8.172551.16780@newshost.lanl.gov> <1992Dec9.060218.23940@seas.gwu.edu>
  9. Date: Sat, 12 Dec 1992 14:20:17 GMT
  10. Lines: 41
  11.  
  12. mfeldman@seas.gwu.edu (Michael Feldman) writes:
  13.  
  14. >You make a good point. Perhaps the modern equivalent of that Fortran
  15. >single-keystroke bug is my favorite bit of C code (and no, I don't
  16. >want to bash C, just point out how common these flukes are):
  17. >
  18. >   int x;
  19. >   ...
  20. >   x = 1;
  21. >   while (x <= 10);
  22. >   { 
  23. >      printf("%d\n", x);
  24. >      x++;
  25. >   }
  26.  
  27. A good compiler would give a warning that the call to printf was
  28. unreachable code. The only compiler I have available, gcc, unfortunately
  29. doesn't give any such warning. But the Pascal-subset compiler I wrote (as one
  30. of the projects for a 3rd-year subject) gives the following warnings for
  31. the equivalent Pascal code:
  32.  
  33. warning: variable 'x' is not used after assignment, so assignment has no effect
  34. warning: 'while' statement will cause an infinite loop
  35.  
  36. >Any similar idiosyncracies in Ada? 
  37.  
  38. The difference between '<' and '>' is only a single keystroke.
  39. More insidious perhaps is the difference between '<' and '<='.
  40. So it can happen even in Ada. 
  41.  
  42. However I do agree that Ada syntax is less error-prone than C or Fortran.
  43. This is not because it is verbose but rather because the Ada designers took
  44. this issue into careful consideration. I believe that it would be quite
  45. possible to design a syntax that was concise but that was no more error-prone
  46. than Ada.
  47.  
  48. -- 
  49. Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
  50. This .signature virus is a self-referential statement that is true - but 
  51. you will only be able to consistently believe it if you copy it to your own
  52. .signature file!
  53.