Skip to content

Commit

Permalink
add guard macro
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Jan 9, 2024
1 parent a262c11 commit f3167bf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## 1.0.0-beta.18
### Features
* add R7RS `guard` macro
### Bugfix
* remove evaluating of async list data as first argument

Expand Down
17 changes: 17 additions & 0 deletions lib/R7RS.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,23 @@
,@body
(--> ,parent (set ',name ,module-var)))))

;; -----------------------------------------------------------------------------
(define-syntax guard
(syntax-rules (catch)
((_ (var cond1 cond2 ...)
body ...)
(try
body ...
(catch (var)
(cond cond1
cond2 ...)))))
"(guard (variable (cond result)
(cond2 result))
body)
Macro that executes the body and when there is exception, triggered by
raise it's saved in variable that can be tested by conditions.")

;; -----------------------------------------------------------------------------
(define-syntax define-library/export
(syntax-rules (rename :c)
Expand Down

0 comments on commit f3167bf

Please sign in to comment.