[clean-list] undefined strictness

Ronny Wichers Schreur ronny@cs.kun.nl
Thu, 15 Jul 2004 18:52:12 +0200


Erik Zuurbier writes (to the Clean mailing list):

> I had always assumed that [..]  the strictness analyser could
> have no particular knowledge about [undef's] divergence.
> Apparently it does.

Yes, undef and abort (from StdMisc) are special cases for the
strictness analyser. They are often used in the last alternative
of a function. For example the function

     f 0 y
         =   y
     f x y
         =   abort ("f " +++ toString x +++ " <> 0")

is strict in its second argument, because of this rule.

The functions "undef" and "abort" are currently hard-wired in
the compiler. Another option would be to look at their types:
undef has type (forall a:a), and only bottom inhabits all types.
An advantage of the latter method would be that you could
write your own undef/abort-like functions, and the strictness
analyser would still recognise that they always evaluate to
bottom.


Cheers,

Ronny Wichers Schreur