[Haskell-beginners] Re: how to read file with locking
Jimmy Wylie
jwylie at uno.edu
Mon Oct 11 01:14:54 EDT 2010
> It is, BTW, always preferable to use withFile over openFile, if you can.
> This makes your code cleaner and also exception-safe.
>
>
>
Hi Ertugrul,
I don't think I quite understand. How is withFile exception-safe?
Under the covers it's using openFile. I was under the impression
withFile was just a nice way to remove boilerplate file operation code.
Here's what I found on hoogle: "withFile
<http://haskell.org/hoogle/?hoogle=withFile> name mode act opens a file
using openFile <http://haskell.org/hoogle/?hoogle=openFile> and passes
the resulting handle to the computation act. The handle will be closed
on exit from withFile <http://haskell.org/hoogle/?hoogle=withFile>,
whether by normal termination or by raising an exception."
Thanks,
Jimmy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20101011/984b7ed4/attachment.html
More information about the Beginners
mailing list