|
Module Lazymodule Lazy:
Deferred computations.
type
A value of type
'a Lazy.t is a deferred computation, called
a suspension, that has a result of type 'a . The special
expression syntax lazy (expr) makes a suspension of the
computation of expr , without computing expr itself yet.
"Forcing" the suspension will then compute expr and return its
result.
Note:
Note: if the program is compiled with the exception Undefined val force : force x forces the suspension x and returns its result.
If x has already been forced, Lazy.force x returns the
same value again without recomputing it. If it raised an exception,
the same exception is raised again.
Raise Undefined if the forcing of x tries to force x itself
recursively.val force_val : force_val x forces the suspension x and returns its
result. If x has already been forced, force_val x
returns the same value again without recomputing it.
Raise Undefined if the forcing of x tries to force x itself
recursively.
If the computation of x raises an exception, it is unspecified
whether force_val x raises the same exception or Undefined .val lazy_from_fun : lazy_from_fun f is the same as lazy (f ()) but slightly more
efficient.val lazy_from_val : lazy_from_val v returns an already-forced suspension of v
This is for special purposes only and should not be confused with
lazy (v) .val lazy_is_val : lazy_is_val x returns true if x has already been forced and
did not raise an exception. |