[Haskell] Re: Haskell Digest, Vol 52, Issue 1
Taral
taralx at gmail.com
Tue Dec 4 17:57:12 EST 2007
On 12/4/07, Simon Marlow <simonmarhaskell at gmail.com> wrote:
> do
> x <- newIVar
> let y = readIVar x
> writeIVar x 3
> print y
>
> (I wrote the let to better illustrate the problem, of course you can inline
> y if you want). Now suppose the compiler decided to evaluate y before the
> writeIVar. What's to prevent it doing that?
Look at the translation:
newIVar >>= (\x -> let y = readIVar x in writeIVar x 3 >> print y)
y can't be floated out because it depends on x.
--
Taral <taralx at gmail.com>
"Please let me know if there's any further trouble I can give you."
-- Unknown
More information about the Haskell
mailing list