On 23-Jul-2000, Julian Assange <[EMAIL PROTECTED]> wrote:
> Jon Fairbairn <[EMAIL PROTECTED]> writes:
> > [George Russell wrote:]
> > > Surely this is obvious to Haskell programmers?
> > to me, anyway.  If two runs (with different flags) of the
> > compiler produce programmes that give different results,
> > then one of them isn't adhering to the standard, (and so
> > should be noted as such).

That statement is not completely true.  The Haskell report does not
completely define the semantics of all Haskell programs.
For example, the range of `Int' and the result of computations
which overflow are left undefined.  Such implementation-dependent
qualities could certainly be subject to change depending on which
compiler flags the user specifies.

Furthermore, not all Haskell programs have deterministic behaviour.
Programs that make non-trivial use of the IO monad can have
nondeterministic behaviour.  In fact, for some programs that make
use of the `Random' module, such as the following,


        import Random
        main = do
                r <- randomRIO (1, 100)
                print (r :: Int)

the whole idea is that you _won't_ get the same result each time.
If the program produces the same results each time then this is
arguably evidence that the implementation does NOT conform to
the Haskell report!

So, the best that you can really say for Haskell is that within a
single run, for code which does not use the IO monad, you should
get the same result each time within that run.

> Microsoft VCC once (still?) suffers from this problem. Whether
> it is because it accesses random, unassigned memory locations
> or because the optimiser has time thesholds, is unknown.

Jon Fairbairn was talking about Haskell.  MSVC is a C/C++ compiler,
not a Haskell compiler.  For C and C++, there are many many areas of
undefined, unspecified, or implementation-defined behaviour.  If a
C or C++ program gives different behaviour on different runs or with
different compilation flags, this is almost always due to the program
depending on one of those areas, rather than due to the compiler not
conforming to the standard.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.

Reply via email to