Global variables?

Jon Cast jcast@ou.edu
Mon, 03 Feb 2003 15:24:49 -0600


Richard Uhtenwoldt <ru@river.org> wrote:
<snip>

> I do not think it is nice: I do not like any of the solutions Hughes
> considers in that paper because this problem can be handled much more
> simply with lexical scope and the IO monad.

can be /= should be

> Just to get our bearings, let us first consider the solution that uses
> unsafePerformIO, which neither Hughes nor I prefer:

> >globalVar :: IORef Int 
> >globalVar = unsafePerformIO $ newIORef 0 
> >foo = fff aaa bbb ccc 
> >bar = ggg xxx yyy zzz 
> >main = mmm >> nnn >> ooo

> where the lines 

> >foo = fff aaa bbb ccc
> >bar = ggg xxx yyy zzz

> stand in for a typically much larger chunk of code --the bulk of the
> program, let us call it.

I, personally, haven't written a program whose bulk will fit in a single
file in several years, and I doubt I ever will again.  So, support for
separate compilation is a necessity.  How do you intend to handle this?

<snip>

Jon Cast