[Haskell-cafe] Re: [Haskell] Top Level <-
Dan Weston
westondan at imageworks.com
Fri Aug 29 19:59:41 EDT 2008
I actually was more interested in the problems with the "obvious fix"
for this, namely the "construct on first use" idiom:
int A(int a) { static int aa = a; return aa; }
int B() { return A(3); }
int C() { return A(7); }
int D() { if (today() == "Tuesday") B(); else C(); return a(0); }
What is the value of D? Notice that this is never a problem with pure
functions. The problem is that today() makes this an IO monad, and the
swearing starts again.
Dan
Bryan O'Sullivan wrote:
> On Fri, Aug 29, 2008 at 4:33 PM, Dan Weston <westondan at imageworks.com> wrote:
>> C++ faced this very issue by saying that with global data, uniqueness of
>> initialization is guaranteed but order of evaluation is not.
>
> In C++ circles, this is referred to as the "static initialization
> order fiasco", and it is a frequent cause of crashes that are very
> difficult to debug.
>
> http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.12
>
> I think it would be fair to say that C++ pushed this problem off to
> every user of the language. I haven't seen a coherent description of
> what the semantics of top-level "<-" should be, but avoidance of
> widespread swearing would be at the top of my list of requirements.
>
>
More information about the Haskell-Cafe
mailing list