blob: 8f740dae2bc9f2948af51fff1603a663cbc87944 (
plain) (
blame)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
(((name . "cond-thunk")
(signature syntax-rules (else)
((_ clause ...)))
(subsigs (clause
(pattern
(expr clause ...)
(else expression1 expression2 ...)))
(expr (or (lambda () *) #f)))
(desc "
* It is an error if `expr` does not evaluate to a thunk or to `#f`.
If `expr` evaluates to a thunk, then the thunk is tail-called as the
result of the expression. Otherwise the macro evalates the next clause. If
the `else` clause is reached, the expressions in the clause are evaluated
as the result of the expression. If there is no `else` clause and all
`expr` fail, then `cond-thunk` returns #f."))
((name . "any-thunk")
(signature case-lambda
((list? thunks) *)
((list? thunks) (procedure? else-thunk) *))
(desc "
* It is an error if `thunks` is not a proper list of thunks that return
either `#f` or another thunk.
* It is an error if `else-thunk` isnot a thunk.
This function is a procedural version of `cond-thunk`.
Evaluate each `thunk` in `thunks` in order. If the `thunk` evaluates to
a thunk, the thunk is tail-called. Otherwise evaluate the next thunk in
the list.
If all `thunks` evaluate to `#f`, then `else-thunk` is tail called. If
`else-thunk` is not supplied, the function returns `#f`."))
((name . "when-ct")
(signature syntax-rules ((_ conditional body ...)))
(desc "
* It is an error if `formal` is not a lambda formal.
* It is an error if `conditional` is not an expression.
If `conditional` is true, return a thunk that when called executes
`body ...`. Otherwise return `#f`."))
((name . "lambda-ct")
(signature syntax-rules ((_ formal conditional body ...)))
(desc "
* It is an error if `formal` is not a lambda formal.
* It is an error if `conditional` is not an expression.
Create a closure with arguments `formal` that evaluates `conditional`.
If `conditional` returns a truthy value, a thunk closure with
`body ...` as its body is returned. Otherwise the closure returns `#f`."))
(name . "define-ct")
(signature syntax-rules ((_ (name . formal) conditional body ...)))
(desc "
* It is an error if `formal` is not a lambda formal.
* It is an error if `conditional` is not an expression.
Define a procedure `name` as a conditional generating a thunk. See
`lambda-ct` for more details."))
|