Common subexpressions are not optimized to single one?

Koji Nakahara yu- at div.club.ne.jp
Wed Dec 3 18:21:10 EST 2003


My original mail might be misleading, but I didn't mean that I want to
rely on the optimization "to make the program work".

I just thought If I could expect such an optimization to be performed,
I would not need to rewrite everytime
> func (g x) (g x) -- g x = unsafeperformIO $ do {...}
to
> let h = g x in func h h
in order to make the program run faster.


But ,in the first place, is it meaningful to write "let h = g x in func h h"
in order to avoid re-evaluation of g x, on the assumption that h is CAF?

Thanks.
--
Koji Nakahara


More information about the Haskell-Cafe mailing list