source: project/wiki/eggref/4/srfi-45 @ 14159

Last change on this file since 14159 was 14159, checked in by Kon Lovett, 11 years ago

Release

File size: 3.1 KB
Line 
1[[tags: egg]]
2
3== srfi-45
4
5Primitives for Expressing Iterative Lazy Algorithms
6
7[[toc:]]
8
9
10== Documentation
11
12Extends the interpretation of a promise to include ''lazy'' and ''eager''
13promises.
14
15For more information see [[http://srfi.schemers.org/srfi-45/srfi-45.html|SRFI 45]].
16
17
18=== Constructors
19
20==== lazy
21
22<syntax>(lazy EXPRESSION) => PROMISE</syntax>
23
24Returns a promise for {{EXPRESSION}}.
25
26The promise will be iteratively forced, overwriting the promise at each step
27before the next iteration, so as to avoid storage leaks.
28
29==== eager
30
31<procedure>(eager EXPRESSION) => PROMISE</procedure>
32
33Returns a promise but immediately evaluates {{EXPRESSION}}.
34
35Not much of a promise, more of a boxed value. For exposition purposes in
36algorithms.
37
38==== delay
39
40<syntax>(delay EXPRESSION) => PROMISE</syntax>
41
42Returns an R5RS promise, a delayed evaluation of {{EXPRESSION}}.
43
44==== d-lay
45
46<syntax>(d-lay EXPRESSION) => PROMISE</syntax>
47
48Returns a {{(lazy (eager EXPRESSION))}} recursive promise.
49
50This routine exists so the R5RS {{delay}} is not redefined.
51
52
53=== Predicates
54
55==== promise?
56
57<procedure>(promise? OBJECT) => BOOLEAN</procedure>
58
59Some kind of promise? An R5RS promise or a recursive promise.
60
61==== recursive-promise?
62
63<procedure>(recursive-promise? OBJECT) => BOOLEAN</procedure>
64
65Recursive promise? A lazy or an eager promise.
66
67==== lazy-promise?
68
69<procedure>(lazy-promise? OBJECT) => BOOLEAN</procedure>
70
71==== eager-promise?
72
73<procedure>(eager-promise? OBJECT) => BOOLEAN</procedure>
74
75
76=== Operations
77
78==== force
79
80<procedure>(force PROMISE) => OBJECT</procedure>
81
82Returns the result of the evaluation of {{PROMISE}}.
83
84
85== Usage
86
87<enscript language=scheme>
88(require-library srfi-45)
89...
90(import srfi-45)
91</enscript>
92
93or
94
95<enscript language=scheme>
96(require-extension srfi-45)
97</enscript>
98
99
100== Examples
101
102
103== Notes
104
105* Unlike the reference implementation this version does not redefine {{delay}}.
106
107
108== Requirements
109
110None
111
112
113== Bugs and Limitations
114
115
116== Author
117
118[[/users/kon lovett|kon lovett]]
119
120
121== Version history
122
123; 2.1.0 : Bug fix for ''too eager'' {{force}}. Removed "box" extension dependency.
124; 2.0.0 : Chicken 4 release.
125
126
127== License
128
129Copyright (C) 2009 Kon Lovett.  All rights reserved.
130
131Permission is hereby granted, free of charge, to any person obtaining a
132copy of this software and associated documentation files (the Software),
133to deal in the Software without restriction, including without limitation
134the rights to use, copy, modify, merge, publish, distribute, sublicense,
135and/or sell copies of the Software, and to permit persons to whom the
136Software is furnished to do so, subject to the following conditions:
137
138The above copyright notice and this permission notice shall be included
139in all copies or substantial portions of the Software.
140
141THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
142IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
143FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
144THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
145OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
146ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
147OTHER DEALINGS IN THE SOFTWARE.
Note: See TracBrowser for help on using the repository browser.