[Haskell-cafe] Re: [Haskell] Re: Global Variables and IO initializers

Jules Bean jules at jellybean.co.uk
Mon Nov 8 07:29:38 EST 2004


On 8 Nov 2004, at 12:23, Lennart Augustsson wrote:

> 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.
>

Yes... a lot of the example we have seen here are 'just' handles. 
newIORef creates handles.  Something many programmers would like is the 
ability to create fresh handles at the toplevel...

Jules



More information about the Haskell-Cafe mailing list