"Ch. A. Herrmann" wrote:

> Hi,
>
>     John> There's an easier way to force structures hyperstrictly. To
>     John> force x to be evaluated to normal form before computing y,
>     John> write (x==x) `seq` y
>
> I'm heavily confused here.
>
> What happens, if
>
>    (a) an optimizer replaces (x==x) by True?

If an optimizer did that it would be severly broken in several ways.
First, there is absolutelty no guarantee that the (==) operator defines
anything that is a reflexive relation.  E.g., I can (for a particular type) define
it to always return False if I like.
Second, even if (==) was defined to be reflexive it's highly likely that
`x==x' would behave differently than `True'.  The former probably
diverges if x is bottom, whereas the latter doesn't.


>
>        If the optimizer is not permitted to do that,
>        its power appears to be limited severely.

Who said Haskell was easy to optimize?

    -- Lennart



Reply via email to