1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"949.43">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #0000ff}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #ad140d}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
16 span
.s1
{font: 18.0px Helvetica
}
17 span
.s2
{font: 9.0px Monaco
}
18 span
.s3
{color: #000000}
19 span
.s4
{color: #0000ff}
20 span
.s5
{color: #001bb9}
21 span
.s6
{color: #2c7014}
22 span
.Apple-tab-span
{white-space:pre
}
26 <p class=
"p1"><span class=
"s1"><b>LazyEnvir
</b></span><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><b>lazy environment
</b></p>
27 <p class=
"p2"><br></p>
28 <p class=
"p1">superclass: EnvironmentRedirect
</p>
29 <p class=
"p2"><br></p>
30 <p class=
"p1">Environment with deferred evaluation and default values.
</p>
31 <p class=
"p2"><br></p>
32 <p class=
"p2"><br></p>
33 <p class=
"p1"><b>put(key, val)
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>sets the value of the reference at
<b>key
</b></p>
34 <p class=
"p1"><b>at(key)
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>returns a reference to the object at
<b>key.
</b><span class=
"Apple-converted-space"> </span></p>
35 <p class=
"p2"><br></p>
36 <p class=
"p3"><span class=
"s3">See also:
<a href=
"../../../Collections/Environment.html">Environment
</a>,
<a href=
"EnvironmentRedirect.html">EnvironmentRedirect
</a>,
<a href=
"ProxySpace.html">ProxySpace
</a></span>.
</p>
37 <p class=
"p1">General overview:
<a href=
"../JITLib.html"><span class=
"s4">JITLib
</span></a></p>
38 <p class=
"p2"><br></p>
39 <p class=
"p1">Consequently, calculations can be done with nonexisting objects which can then be assigned later.
</p>
40 <p class=
"p1">Per default, a LazyEnvir returns instances of
<a href=
"Maybe.html"><span class=
"s4">Maybe
</span></a>. See also
<a href=
"../Patterns/Fdef.html"><span class=
"s4">Fdef
</span></a>.
</p>
41 <p class=
"p4"><br></p>
42 <p class=
"p4"><br></p>
43 <p class=
"p5">// examples
</p>
44 <p class=
"p4"><br></p>
45 <p class=
"p6">l =
<span class=
"s5">LazyEnvir
</span>.push;
</p>
46 <p class=
"p4"><br></p>
47 <p class=
"p5">// default objects are created on access
</p>
48 <p class=
"p6">~a;
<span class=
"Apple-converted-space"> </span></p>
49 <p class=
"p5"><span class=
"s3">~a.value;
</span>// defaults to
1</p>
50 <p class=
"p4"><br></p>
51 <p class=
"p5">// operations on placeholders
</p>
53 <p class=
"p6">~c = ~a + ~b;
</p>
54 <p class=
"p4"><br></p>
55 <p class=
"p6">~c.value;
</p>
57 <p class=
"p4"><br></p>
58 <p class=
"p4"><br></p>
59 <p class=
"p5">// variables can be assigned later
</p>
61 <p class=
"p6">~a =
800;
</p>
62 <p class=
"p6">~b = {
1.0.rand };
</p>
63 <p class=
"p4"><br></p>
64 <p class=
"p6">~c.value;
<span class=
"Apple-converted-space"> </span></p>
66 <p class=
"p4"><br></p>
67 <p class=
"p4"><br></p>
68 <p class=
"p5">// variables can be exchanged later
</p>
70 <p class=
"p6">~b = {
1000.rand };
<span class=
"Apple-converted-space"> </span></p>
71 <p class=
"p6">~c.value;
<span class=
"Apple-converted-space"> </span></p>
73 <p class=
"p4"><br></p>
74 <p class=
"p4"><br></p>
75 <p class=
"p5">// making pattern space using LazyEnvir
</p>
76 <p class=
"p4"><br></p>
77 <p class=
"p6">a =
<span class=
"s5">LazyEnvir
</span>.new;
</p>
78 <p class=
"p6">a.proxyClass=
<span class=
"s6">\PatternProxy
</span>;
</p>
79 <p class=
"p4"><br></p>
80 <p class=
"p6">a.push;
</p>
81 <p class=
"p4"><br></p>
82 <p class=
"p6">~x =
<span class=
"s5">Pseq
</span>([
1,
2,
30],
1);
</p>
83 <p class=
"p6">~y =
<span class=
"s5">Pseq
</span>([~x],
<span class=
"s5">inf
</span>);
</p>
84 <p class=
"p4"><br></p>
85 <p class=
"p6">z = ~y.asStream;
</p>
86 <p class=
"p4"><br></p>
87 <p class=
"p6">z.next;
</p>
88 <p class=
"p6">z.next;
</p>
89 <p class=
"p6">z.next;
</p>
90 <p class=
"p6">~x =
<span class=
"s5">Pseq
</span>([
100,
2,
300],
1);
</p>
91 <p class=
"p6">z.next;
</p>
92 <p class=
"p6">z.next;
</p>
93 <p class=
"p6">z.next;
</p>
94 <p class=
"p4"><br></p>
95 <p class=
"p6">a.pop;
</p>