Check if the space leak that is avoided in the following code fragment by making "f" part of "'a comp" happens in some form also in the Babel-17 implementation of memoize .
datatype 'a comp = NotComputed of (unit -> 'a) | Computed of 'a | Exception of exn
fun memo f =
let
val result = ref (NotComputed f)
fun g () =
case !result of
NotComputed f =>
let val r = f() in
result := Computed r;
r
end handle e =>
(result := Exception e; raise e)
| Computed r => r
| Exception e => raise e
in
g
end
Check if the space leak that is avoided in the following code fragment by making "f" part of "'a comp" happens in some form also in the Babel-17 implementation of memoize .