[Haskell-cafe] global variables
Isaac Dupree
isaacdupree at charter.net
Fri May 18 16:34:06 EDT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Adrian Hey wrote:
> Furthermore, if it is going to take this state handle as an explicit
> argument then you need to provide some way for users to get this
> state handle. This could be by..
> 1 - Making it an argument of main.
> 2 - Exposing a newLibWhateverState constructor
> 3 - Exposing a getLibWhateverState "getter".
>
> Problems..
> 1 Requires the type of main to depend on what IO libs are used.
> Also the Boot code that invokes main must get this state handle
> from somewhere.
> 2 Potentially permits 2 or more libWhateverStates to be created
> (in which case all bets are off re. the safety proprties I was
> talking about).
> 3 Can't be implemented without making use of..you know what.
Making it an argument of main (1) is somewhat the same as doing (3) -
consider getArgs. What bothers me is the IO-state in the Haskell
standard (arguments, random state...) which is a set not extensible
without the hack. (It bothers me that there _are_ so many things in
that set, somewhat ad-hoc-ly it seems :)
> Unfortunately the situation seems worse than this. AFAICT we haven't
> even got a consensus that that there is a real problem here that needs
> any kind of solution :-)
The unsafePerformIO hack being used is not very satisfactory given how
many optimizations make it difficult to use safely in practice. This
hack is also used many places. I would be happier if that situation
were not true, and I suspect there's something like a consensus on
_that_. (maybe not as strong as "_needs_ a solution" in the short-to-mid
term future)
Isaac
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGTg2+HgcxvIWYTTURAvWfAKC36q24IKTX5YQOVi+A4gNYLzBMMACePwkL
dwnAlZh++e2EqiFKvJEmn1M=
=NBHG
-----END PGP SIGNATURE-----
More information about the Haskell-Cafe
mailing list