[Haskell-cafe] Re: [Haskell] Re: Global Variables and
lennart at augustsson.net
Mon Nov 8 07:23:03 EST 2004
Adrian Hey wrote:
> 4- They already exist (stdin,stout,stderr) and I don't
> recall anybody ever complaining about this.
stdin, stdout, and stderr are not global variables.
They are just handles. One possible implementation
of handles is as an Int. So stdin is no more a global
variable than 0. Of course you need some state
associated with the handle, but that state does not
have to be a unique global things. You are passing
that state around via the IO monad, and there could
be multiple versions of it. GHC chooses to implement
it differently, but that's a choice.
More information about the Haskell-Cafe