aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2024-12-31 00:18:24 -0500
committerGravatar Peter McGoron 2024-12-31 00:18:39 -0500
commitf37a28fd738c6f17b11e950a0c9d859ce8f1d832 (patch)
tree90528018dc14106e24443f83454b1afe882a079a
parentadd on-error! (diff)
documentation
-rw-r--r--cond-thunk.egg2
-rw-r--r--doc/mcgoron.cond-thunk.values.scm14
2 files changed, 14 insertions, 2 deletions
diff --git a/cond-thunk.egg b/cond-thunk.egg
index 1472c7f..36f472b 100644
--- a/cond-thunk.egg
+++ b/cond-thunk.egg
@@ -1,5 +1,5 @@
((author "Peter McGoron")
- (version "0.2.0")
+ (version "0.2.1")
(synopsis "macros for abstracting conditional branches")
(category "lang-exts")
(license "Apache-2.0")
diff --git a/doc/mcgoron.cond-thunk.values.scm b/doc/mcgoron.cond-thunk.values.scm
index c319f3d..4067594 100644
--- a/doc/mcgoron.cond-thunk.values.scm
+++ b/doc/mcgoron.cond-thunk.values.scm
@@ -3,7 +3,8 @@
(subsigs
(clause (pattern
((when conditional))
- ((let value => formal)))))
+ ((let value => formal))
+ ((on-error! expr)))))
(desc "
For each clause,
@@ -14,6 +15,17 @@ For each clause,
`value` returns no values, then the `after` expression returns `#f`.
Otherwise, the values returned are bound to `formal` in the next clauses
and in the body.
+* If `clause` is `on-error! expr`, then the next failed clause will execute
+ `expr`. The expression will be executed in the scope of all previous
+ declarations.
+
+ The `on-error!` clause works by returning the result thunk to any
+ enclosing `cond-thunk` expression before the next clauses are evaluated.
+ The execution of the rest of the clauses continues in the returned thunk,
+ with failures tail-calling a thunk that executes `expr`. The `on-error!`
+ clause is simliar to `cut` in logic programming languages, because it
+ prevents backtracking to an enclosing `cond-thunk`. It was originally
+ called `cut!`.
Once all clauses succeed, the `after` clause returns a thunk containing
body. The free variables bound in and surrounding the `after` expression