On Thu, Dec 29, 2011 at 12:28 PM, Donn Cave d...@avvanta.com wrote:
Quoth Antoine Latter aslat...@gmail.com,
...
Would this program then loop:
append fromFilePath toFilePath = do
str - readFile fromFile
writeFile toFile str
if 'from' and 'to' where the same file?
Currently the locking prevents this.
Do you mean, locking makes that work, or just makes it fail in a
different way? Anyway, I think that's an example that would have
the same issues without hGetContents - that is, any way you set
out to overwrite a file by modifying its contents, you have the
same problem.
Locking makes this fail with an exception, I think. Not locking would
make this mis-behave.
And lets pretend I wrote the function that was in my head:
append fromFilePath toFilePath = do
str - readFile fromFile
appendFile toFile str
Here, without locking, I would expect to fill my disk up, whereas
previously my program would have crashed before writing out any data.
Maybe these are pathological examples, but they are (I think!) the
justification for having the locking in the first place.
Antoine
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe