Mark Utting writes:
> 
> As a simplified example of this, the following Haskell command
> 
>    do {s<- readFile "data"; writeFile "data" "123"; putStrLn s}
> 
> always displays "123", rather than the original contents of the file.
> 
> I think this is a bug?  I/O commands should conceptually be done
> in the order that they appear in the 'do' sequence?
> If it is a bug, it exists in Hugs 1.3, Jan98 1.4, and June98 1.4.
> 

Yes, it's a bug. An implementation of the Haskell IO spec should as
far as possible implement process-local file locking. Specifically,
when you open "data" in WriteMode (via writeFile), an exception should
be raised. See 11.3.1 of the 1.4 library report for details.

I don't know if the Hugs implementation does or doesn't implement file
locking, perhaps its an artifact of the platform you're working on?
(i.e., no device numbers & i-nodes readily at hand.)

--Sigbjorn

Reply via email to