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

Peter Simons simons at cryp.to
Mon Nov 8 01:00:51 EST 2004

Benjamin Franksen writes:

 > Even in C++ using global variables is nowadays generally
 > regarded as bad design, especially for libraries.

Well, to be fair one has to say that they are still quite
popular although people call them "singletons" and other
cute things these days. I distinctly remember reading
hundreds and hundreds of articles which explained in great
detail how to create and use them in slightly less than 200
lines of template meta-programming code without making the
compiler explode and still getting the result you expected
almost half of the time. Of course, if you used
multi-threading it all exploded nonetheless then.

So the discussion about global IO initializers in Haskell is
slightly reminiscent of that for me.

The argument in favor of global variables usually was that
it was "more comfortable", which means that using them saved
you a total of 20 seconds per-module because you had a
parameter less to type every now and then, at the small cost
of making your code almost unmaintainable in the long run.

Frankly, the idea that anyone would want to jump through
hoops to add them to a purely functional language sounds
bizarre to me. But by all means, as long as the compiler
extension is disabled per default I won't mind. :-)


More information about the Haskell-Cafe mailing list