From: sof Date: Wed, 3 Sep 1997 23:41:45 +0000 (+0000) Subject: [project @ 1997-09-03 23:41:45 by sof] X-Git-Tag: Approximately_1000_patches_recorded~57 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=b0ef36bb7b5e0374b8532822eb667aec752c928c;p=ghc-hetmet.git [project @ 1997-09-03 23:41:45 by sof] seq now operational --- diff --git a/ghc/lib/required/Prelude.lhs b/ghc/lib/required/Prelude.lhs index 054e3e3..ce24d75 100644 --- a/ghc/lib/required/Prelude.lhs +++ b/ghc/lib/required/Prelude.lhs @@ -73,13 +73,24 @@ import GHCerr strict :: Eval a => (a -> b) -> a -> b strict f x = x `seq` f x + +-- "seq" is defined a bit wierdly (see below) +-- +-- The reason for the strange "0# -> parError" case is that +-- it fools the compiler into thinking that seq is non-strict in +-- its second argument (even if it inlines seq at the call site). +-- If it thinks seq is strict in "y", then it often evaluates +-- "y" before "x", which is totally wrong. +-- +-- Just before converting from Core to STG there's a bit of magic +-- that recognises the seq# and eliminates the duff case. + {-# INLINE seq #-} seq :: Eval a => a -> b -> b -#ifdef __CONCURRENT_HASKELL__ -seq x y = case (seq# x) of { 0# -> parError; _ -> y } -#else -seq x y = y -- WRONG! -#endif +seq x y = case (seq# x) of { 0# -> seqError; _ -> y } + +seqError :: a +seqError = error "Oops! Entered seqError (a GHC bug -- please report it!)\n" -- It is expected that compilers will recognize this and insert error -- messages which are more appropriate to the context in which undefined