re-opening a closed stdin?
Bernard James POPE
bjpop@cs.mu.OZ.AU
Thu, 21 Nov 2002 17:25:08 +1100 (EST)
Simon Marlow writes:
> I've been thinking about duplicating/replacing Handles for a while.
> Here's a possible interface:
>
> -- |Returns a duplicate of the original handle, with its own buffer
> -- and file pointer. The original handle's buffer is flushed,
> including
> -- discarding any input data, before the handle is duplicated.
> hDuplicate :: Handle -> IO Handle
> -- |Makes the second handle a duplicate of the first handle. The
> -- second handle will be closed first, if it is not already.
> hDuplicateTo :: Handle -> Handle -> IO ()
I'm not too sure of the issues here. Some examples that use them would be
helpful.
The only suggestion I'd make is that the names be something with handle in
them:
huDupHandle, hDupHandleTo
> The remaining questions are:
> - Should you be allowed to duplicate a Handle which refers
> to a file opened in WriteMode? Haskell 98 forbids having
> two Handles pointing to the same file opened for writing,
> but IMHO it's quite a reasonable thing to do. If we don't allow
> this, then there needs to be another version of hDuplicateTo
> which invalidates the original Handle.
Why does Haskell 98 make this restriction (I don't think that the library
report says why)?
Thanks,
Bernie.