home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / ada / 3908 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  2.8 KB

  1. Path: sparky!uunet!think.com!enterpoop.mit.edu!mintaka.lcs.mit.edu!ai-lab!life.ai.mit.edu!tmb
  2. From: tmb@arolla.idiap.ch (Thomas M. Breuel)
  3. Newsgroups: comp.lang.ada
  4. Subject: Re: An Ada Program Does What It Says?
  5. Date: 7 Jan 93 11:51:40
  6. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  7.     Perceptive)
  8. Lines: 45
  9. Message-ID: <TMB.93Jan7115140@arolla.idiap.ch>
  10. References: <9301031530.AA17787@ajpo.sei.cmu.edu> <1993Jan4.082827.11773@hellgate.utah.edu>
  11.     <1993Jan6.215758.10007@mksol.dseg.ti.com>
  12. Reply-To: tmb@idiap.ch
  13. NNTP-Posting-Host: arolla.idiap.ch
  14. In-reply-to: mccall@mksol.dseg.ti.com's message of Wed, 6 Jan 1993 21:57:58 GMT
  15.  
  16. In article <1993Jan6.215758.10007@mksol.dseg.ti.com> mccall@mksol.dseg.ti.com (fred j mccall 575-3539) writes:
  17.  
  18.    >Stuff like expression ordering, floating point representation, concurency,
  19.    >etc, will always be indeterminate.
  20.  
  21.    >Not to trigger yet another C vs Ada flamefest, but this expression in
  22.    >C is a classic example...
  23.  
  24.    >  r = (i++ == ++i)            [*]
  25.  
  26.    It is also, of course, quite well documented and understood.  You are
  27.    correct in stating that just about every language is going to have
  28.    syntactically correct constructs which produce undefined or
  29.    implementation-defined results.  You are, however, incorrect in your
  30.    assumption that Ada is the only language in which these things are
  31.    well documented or understood.
  32.  
  33. First, there are different degrees of undefined behavior. For example,
  34. you could mandate that any result of expression [*] is going to
  35. correspond to one particular order of evaluation. In particular, that
  36. would mean that the effects of writing [*] would be limited to the
  37. variables mentioned in the statement. I believe in the case of
  38. order-of-evaluation dependencies, this is what C does, but for other
  39. "undefined behavior" (notably, pointer errors), the effects are not
  40. limited.
  41.  
  42. Language specs can make an effort to mandate features that make the
  43. detection of bugs due to "undefined behavior" easier, for example, by
  44. mandating compiler options that excercise the different possibilities.
  45. Some implementations do this, but I don't know of any language
  46. standard that even recommends it.
  47.  
  48. But more importantly, these sources of "indeterminacy" ("undefined
  49. behavior) can be eliminated completely.  You can define order of
  50. evaluation, you can eliminate side effects, you can mandate a
  51. particular floating point representation, and/or you can choose models
  52. of parallel computation that do not give rise to "indeterminacy".
  53.  
  54. I believe neither Ada nor C go far enough in this regard, although I
  55. suspect that Ada is somewhat better than C. The only languages that I
  56. know of that go much further in eliminating undefined behavior have
  57. parted with the Pascal heritage (the Pascal type system, imperative
  58. updates, processes, ...).
  59.  
  60.                     Thomas.
  61.