FW: showing Handle is impure
Simon Marlow
simonmar@microsoft.com
Tue, 22 Jul 2003 10:10:01 +0100
=20
> I share Alastair's concern about the possibility that a=20
> handle may not always
> contain a filename. I think it would be cleaner to assume=20
> that the only immutable
> part of a handle is its identity. And it is important that=20
> the identity be shown (that is, as by `show`).
First, on the filename: it was misleading of me to call it a filename.
I should really have called it something like the "handle description" -
it's just a string telling you something about the Handle. In the case
of a Handle to a file, we use the filename for the description. For
stdin, we use the string "<stdin>", for a socket we use the string
"<socket: FD>" (where FD is the file descriptor). It's clearly useful
to be able to display this stuff when showing a Handle.
On Handle identities: yes, Handles have an identity, but in GHC's
implementation there isn't a way to encode this identity as a String
(because the identity is inherrent in the Handle's location in memory,
and that location changes from time to time due to GC).
We could embed another Integer identity in the Handle, but I'm not
convinced it's that useful. If you want to get at the Handle identity,
say for making a mapping from Handles, you can use StableNames (hey, a
use for StableNames :-).
Cheers,
Simon