Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible fix for #143 #146

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions level1/impl.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
(lambda (clause last?)
(ematch0 clause
((list* pattern body)
((lambda (x) (if last? x `(block clause ,x)))
((lambda (x) (if last? x `(with-clause ,x)))
;; << (return-from clause) = go to next clause
;; the last pattern does not have this block, allowing a direct jump to the upper block
(match-clause arg
Expand All @@ -77,9 +77,16 @@
((cons it rest)
(cons (funcall fn it nil) (mapcar1-with-last fn rest)))))

(defmacro with-clause (&body body)
`(block clause
(macrolet ((skip () `(next))
(with-clause (&body body)
`(block clause ,@body)))
,@body)))

(defmacro next () `(return-from clause nil))
(defmacro fail () `(next))
(defmacro skip () `(next))
(defmacro skip () `())

;;;; catch-based `next' implementation
;; using catch is not appropriate for our purpose, according to CLHS,
Expand Down