Global variables?

Nick Name nick.name@inwind.it
Fri, 31 Jan 2003 15:19:23 +0100


On Fri, 31 Jan 2003 07:47:43 +0000
Glynn Clements <glynn.clements@virgin.net> wrote:

>  The usual fudge is:
>=20
>  	import IORef
>  	import IOExts
>  =09
>  	globalVar :: IORef Int
>  	globalVar =3D unsafePerformIO $ newIORef 0

I see in the documentation of unsafePerformIO that no one makes
guarantees about the order in wich unsafePerformIO arguments are
performed (especially they don't have to be executed BEFORE main), so
this trick should not be adviced as a general practice; it should be
pointed out that it works in GHC but could not work in other compilers.

Vincenzo

--=20
Fedeli alla linea, anche quando non c'=E8 Quando l'imperatore =E8
malato, quando muore,o =E8 dubbioso, o =E8 perplesso.  Fedeli alla linea
la linea non c'=E8.  [CCCP]