comp.lang.ada
 help / color / mirror / Atom feed
From: agate!spool.mu.edu!think.com!enterpoop.mit.edu!mintaka.lcs.mit.edu!ai-lab !life.ai.mit.edu!tmb@ucbvax.Berkeley.EDU  (Thomas M. Breuel)
Subject: Re: An Ada Program Does What It Says?
Date: 7 Jan 93 19:51:40 GMT	[thread overview]
Message-ID: <TMB.93Jan7115140@arolla.idiap.ch> (raw)

In article <1993Jan6.215758.10007@mksol.dseg.ti.com> mccall@mksol.dseg.ti.com (
fred j mccall 575-3539) writes:

   >Stuff like expression ordering, floating point representation, concurency,
   >etc, will always be indeterminate.

   >Not to trigger yet another C vs Ada flamefest, but this expression in
   >C is a classic example...

   >  r = (i++ == ++i)			[*]

   It is also, of course, quite well documented and understood.  You are
   correct in stating that just about every language is going to have
   syntactically correct constructs which produce undefined or
   implementation-defined results.  You are, however, incorrect in your
   assumption that Ada is the only language in which these things are
   well documented or understood.

First, there are different degrees of undefined behavior. For example,
you could mandate that any result of expression [*] is going to
correspond to one particular order of evaluation. In particular, that
would mean that the effects of writing [*] would be limited to the
variables mentioned in the statement. I believe in the case of
order-of-evaluation dependencies, this is what C does, but for other
"undefined behavior" (notably, pointer errors), the effects are not
limited.

Language specs can make an effort to mandate features that make the
detection of bugs due to "undefined behavior" easier, for example, by
mandating compiler options that excercise the different possibilities.
Some implementations do this, but I don't know of any language
standard that even recommends it.

But more importantly, these sources of "indeterminacy" ("undefined
behavior) can be eliminated completely.  You can define order of
evaluation, you can eliminate side effects, you can mandate a
particular floating point representation, and/or you can choose models
of parallel computation that do not give rise to "indeterminacy".

I believe neither Ada nor C go far enough in this regard, although I
suspect that Ada is somewhat better than C. The only languages that I
know of that go much further in eliminating undefined behavior have
parted with the Pascal heritage (the Pascal type system, imperative
updates, processes, ...).

					Thomas.

             reply	other threads:[~1993-01-07 19:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-01-07 19:51 agate!spool.mu.edu!think.com!enterpoop.mit.edu!mintaka.lcs.mit.edu!ai-lab [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-01-06 21:57 An Ada Program Does What It Says? agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state
1993-01-05 16:52 David Emery
1993-01-04 19:37 Bjarne Stroustrup
1993-01-04 15:28 agate!spool.mu.edu!uwm.edu!caen!hellgate.utah.edu!peruvian.cs.utah.edu!ma
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox