[Haskell-cafe] One-shot? (was: Global variables and stuff)
gk at ninebynine.org
Tue Nov 9 06:53:44 EST 2004
I've not been following the Global variables debate too closely, it seeming
to have something of a religious wars flavour, but I noticed that an
example being proposed was how to achieve a "one shot" execution. Here's
something I did when working on modifications to the HaXML parser:
-- Memoization of withSocketsDo to prevent multiple calls.
-- (cf. http://tangentsoft.net/wskfaq/articles/lame-list.html)
socketsInitialized :: Bool
socketsInitialized = unsafePerformIO ( withSocketsDo ( return True ) )
Does it work as I think it does? ARe there any problems I'm overlooking?
More information about the Haskell-Cafe