Tim <[EMAIL PROTECTED]> wrote:

> For example, consider a program where one thread prints a value from an MVar,
> while another thread modifies it. The output of the program will vary from one
> run to another, even though its input (none) is unchanged.

This is not a result of using concurrency.
You see the same no input/different output behaviour in a program as
simple as this:

> import Random
> main = getStdRandom (randomR (False,True)) >>= print

(Or use the Time library.)

And nothing of this breakes referential transparency.
For example, 

> main = randomints >>= print
> randomints :: IO (Int,Int)
> randomints = do a <- getStdRandom (randomR (1,100))
>                 b <- getStdRandom (randomR (1,100))
>                 return (a,b)

has the same possible results as

> main = randomints >>= print
> randomints :: IO (Int,Int)
> randomints = let rnd = getStdRandom (randomR (1,100)) in
>              do a <- rnd; b <- rnd      
>                 return (a,b)

Each time a program is run it is given a different world to start
with.
C is as referentially transparent as you are willing to agree that
each function has an implicit IO in its type, which won't gain you
anything. Even that is not really enough. "volatile" variables are
MVars, and what are non-volatile variables changed in signal
handlers? Uncaught type errors? Enough of that.

All the best,
Christian Sievers



Reply via email to