[Haskell] Re: Global Variables and IO initializers
Adrian Hey
ahey at iee.org
Fri Nov 5 13:15:20 EST 2004
On Friday 05 Nov 2004 1:23 pm, Marcin 'Qrczak' Kowalczyk wrote:
> Keean Schupke <k.schupke at imperial.ac.uk> writes:
> > Why do want global variables?
>
> Because they are more convenient than passing a state by hand.
> They increase modularity by avoiding putting the fact that
> a computation uses some global state in its type.
>
> You don't want stdin/stdout/stderr?
IMHO this thread is somewhat misnamed anyway, for 2 reasons
1- We're not talking about simple mutable variables, we're
talking about the safe construction of arbitrary "things
with identity" without breaking referential transparency
by use of unsafePerformIO hack.
2- These things are "top level", but almost certainly aren't
"global" in most cases.
As Marcin has pointed out, we happily make use of such things
anyway, as provided by existing libraries. So the fact that
these things exist (and can be used quite safely) but the
language provides no way for the programmer to safely create
them seems a bit strange.
Regards
--
Adrian Hey
More information about the Haskell
mailing list