Hi David,

My best guess is that the conservative garbage collector is missing a heap
reference on the C stack.  Here's a few things to try:

1) Rerun with "+g" so that you can see when GC happens.
2) Rerun with a ridiculously large heap so that GC doesn't happen.
3) If the above confirm my guess, recompile Hugs with optimisation
   turned off.

Failing that, you could send the code direct to me and I'll try it out 
with Visual C++ myself.  (I presume you're using NT 4.0)


Alastair

ps Haskell compilers tend to do a terrible job compiling code like:

   foo "abcd" = e1
   foo "efgh" = e2
   foo "ijkl" = e3

   The language semantics says this is equivalent to:

   foo 'a':'b':'c':'d':[] = ...
   foo 'e':'f':'g':'h':[] = ...
   foo 'i':'j':'k':'l':[] = ...

   Which is usually translated into code like this:

     foo x1 = case x of
              x1 : x2 -> case x1 of
                         'a' -> case x2 of 
                                x3 : x4 -> case x3 of
                                           'b' -> ... etc ...
                                           _ -> fail
                                _ -> fail
                         'e' -> similar
                         'i' -> similar
              _ -> fail
       where
        fail = error "Pattern match failure"

   The total amount of code generated is something like 27 case expressions.

   On most compilers, you'll get much better code if you write:

     foo s = 
       fromMaybe 
            (error "...")
            ( lookup s 
              [ ("abcd", e1)
              , ("efgh", e2)
              , ("ijkl", e3)
              ]
            )

Reply via email to