
On Monday 08 Nov 2004 3:57 pm, Keith Wansbrough wrote:
[posted to haskell-cafe per SLPJ's request]
Hi Adrian,
I can assure you that for the intended applications of oneShot it is vital that realInit is executed once at most, but the user must
[..]
So please, no more handwaving arguments about this kind of thing being unnecessary, bad programming style, or whatever..
Please show me a concrete alternative in real Haskell code, other
I'm mystified as to why you are insisting others provide real examples when you are not.
Maybe you should read the whole thread. AFAIK I am the only person who has provided a concrete example of anything, and I did so in direct response to a request to do so from Keaan IIRC. Unfortunately my own requests for counter examples showing that there are safer (easier, more elegant or whatever) solutions have been ignored (not that I'm in the least bit surprised by this). Instead all I get is repeated denial of the reality of this problem. The problem is simple enough to restate for anyone who's interested. "Provide a simple reliable mechanism to ensure that in a given program run one particular top level IO operation cannot be executed more than once."
Can you give one concrete example of an "intended application of oneShot", so that we can either propose a concrete Haskell implementation of it, or agree that global variables really are necessary.
Any C library which requires an explicit initialisation call before anything in that library can be used (common enough IME). Accidental re-initialisation (e.g. by two independent modules/libraries) will destroy any state currently be used by the libraries existing "clients". The need to do this may or may not indicate "bad design" on the part of the library author. But so what? It just happens to be a fact that must be dealt with from Haskell (in a safe manner preferably). Regards -- Adrian Hey