File: manual042.html

package info (click to toggle)
ocaml-doc 2.04-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,820 kB
  • ctags: 997
  • sloc: makefile: 38; sh: 12
file content (43 lines) | stat: -rw-r--r-- 1,591 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset= ISO-8859-1">
<TITLE>
 Module Lazy: deferred computations.
</TITLE>
</HEAD>
<BODY >
<A HREF="manual041.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual043.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<HR>

<H2>17.12&nbsp;&nbsp; Module <TT>Lazy</TT>: deferred computations.</H2><A NAME="s:Lazy"></A>
<A NAME="@manual336"></A><PRE>
type 'a status =
  | Delayed of (unit -&gt; 'a)
  | Value of 'a
  | Exception of exn
;;
type 'a t = 'a status ref;;
</PRE>
<BLOCKQUOTE>
A value of type <CODE>'a Lazy.t</CODE> is a deferred computation (also called a
suspension) that computes a result of type <CODE>'a</CODE>. The expression
<CODE>lazy (expr)</CODE> returns a suspension that computes <CODE>expr</CODE>.</BLOCKQUOTE>
<PRE>
val force: 'a t -&gt; 'a;;
</PRE>
<A NAME="@manual337"></A><BLOCKQUOTE>
<CODE>Lazy.force x</CODE> computes the suspension <CODE>x</CODE> and returns its result.
If the suspension was already computed, <CODE>Lazy.force x</CODE> returns the
same value again. If it raised an exception, the same exception is
raised again.</BLOCKQUOTE>

<HR>
<A HREF="manual041.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual043.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
</BODY>
</HTML>