[Haskell-cafe] Re: Global Variables and IO initializers
ger at informatik.uni-bremen.de
Fri Nov 26 02:26:17 EST 2004
Marcin wrote (snipped):
> I think global variables are a lot less evil if they behave as if they
> were dynamically scoped, like Lisp special variables.
> That is, there is a construct which gives the variable a new mutable
> binding visible in the given IO action. It's used more often than
> assignment. Assignment is still available though.
I agree entirely. The fact that declaring global variables using unsafePerformIO
introduces an artificial notion of "global" and forces it on every part of the
program is a major disadvantage which we haven't heard enough about in this
discussion. It prevents you doing all sorts of things. It's bad for parallelism.
It prevents you running two independent copies of a (main) action. It prevents
you writing a Haskell controller which runs over Haskell actions as subprograms.
More information about the Haskell-Cafe