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

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

Rel 2.2.0

File size: 3.3 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>(delay-recursive EXPRESSION) => PROMISE</syntax>
47<syntax>(d-lay EXPRESSION) => PROMISE</syntax>
48
49Returns a {{(lazy (eager EXPRESSION))}} recursive promise.
50
51This routine exists so the R5RS {{delay}} is not redefined.
52
53
54=== Predicates
55
56==== promise?
57
58<procedure>(promise? OBJECT) => BOOLEAN</procedure>
59
60Some kind of promise? An R5RS promise or a recursive promise.
61
62==== recursive-promise?
63
64<procedure>(recursive-promise? OBJECT) => BOOLEAN</procedure>
65
66Recursive promise? A lazy or an eager promise.
67
68==== lazy-promise?
69
70<procedure>(lazy-promise? OBJECT) => BOOLEAN</procedure>
71
72==== eager-promise?
73
74<procedure>(eager-promise? OBJECT) => BOOLEAN</procedure>
75
76
77=== Operations
78
79==== force
80
81<procedure>(force PROMISE) => OBJECT</procedure>
82
83Returns the result of the evaluation of {{PROMISE}}.
84
85
86== Usage
87
88<enscript language=scheme>
89(require-library srfi-45)
90...
91(import srfi-45)
92</enscript>
93
94or
95
96<enscript language=scheme>
97(require-extension srfi-45)
98</enscript>
99
100
101== Examples
102
103
104== Notes
105
106* Unlike the reference implementation this version does not redefine {{delay}}.
107
108
109== Requirements
110
111None
112
113
114== Bugs and Limitations
115
116
117== Author
118
119[[/users/kon lovett|kon lovett]]
120
121
122== Version history
123
124; 2.2.0 : Bug fix for ''lazy'' R5RS promise in {{force}}. [Reported by Derrell Piper]
125; 2.1.0 : Bug fix for ''too eager'' {{force}}. Removed "box" extension dependency.
126; 2.0.0 : Chicken 4 release.
127
128
129== License
130
131Copyright (C) 2009 Kon Lovett.  All rights reserved.
132
133Permission is hereby granted, free of charge, to any person obtaining a
134copy of this software and associated documentation files (the Software),
135to deal in the Software without restriction, including without limitation
136the rights to use, copy, modify, merge, publish, distribute, sublicense,
137and/or sell copies of the Software, and to permit persons to whom the
138Software is furnished to do so, subject to the following conditions:
139
140The above copyright notice and this permission notice shall be included
141in all copies or substantial portions of the Software.
142
143THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
144IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
145FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
146THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
147OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
148ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
149OTHER DEALINGS IN THE SOFTWARE.
Note: See TracBrowser for help on using the repository browser.