more unsafePerformIO questions (is it safe to use with
ReadMode Handles)?
Ganesh Sittampalam
ganesh@earth.li
Tue, 19 Aug 2003 11:11:23 +0100
On Tue, 19 Aug 2003 10:52:57 +0100, "Simon Marlow" <simonmar@microsoft.com>
wrote:
>> Isn't there the possibility of inlining causing a read to
>> happen twice even if it only appears to happen once?
>
>In theory that would be a valid transformation, but in practice no
>compiler would duplicate arbitrary computations. GHC certainly doesn't.
I was thinking of a situation like
let x = unsafePerformIO readFooFromDB in x+x
I see from your "Secrets of the GHC inliner" paper that x wouldn't be
inlined by GHC, but it seems to me like a serious abuse of the principle of
referential transparency to write programs that _assume_ that.
Cheers,
Ganesh