mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 19:50:24 +02:00
Failed match errors generate less code
* module/ice-9/match.upstream.scm (match-next): Call out to an external procedure on error, and use a begin instead of double-parens. This results in less generated code.
This commit is contained in:
parent
58dee5b9e4
commit
4a565538bd
1 changed files with 9 additions and 4 deletions
|
@ -280,14 +280,19 @@
|
||||||
;; clauses. `g+s' is a list of two elements, the get! and set!
|
;; clauses. `g+s' is a list of two elements, the get! and set!
|
||||||
;; expressions respectively.
|
;; expressions respectively.
|
||||||
|
|
||||||
|
(define (match-error v)
|
||||||
|
(error 'match "no matching pattern" v))
|
||||||
|
|
||||||
(define-syntax match-next
|
(define-syntax match-next
|
||||||
(syntax-rules (=>)
|
(syntax-rules (=>)
|
||||||
;; no more clauses, the match failed
|
;; no more clauses, the match failed
|
||||||
((match-next v g+s)
|
((match-next v g+s)
|
||||||
;; Here we wrap error within a double set of parentheses, so that
|
;; Here we call match-error in non-tail context, so that the
|
||||||
;; the call to 'error' won't be in tail position. This allows the
|
;; backtrace can show the source location of the failing match
|
||||||
;; backtrace to show the source location of the failing match form.
|
;; form.
|
||||||
((error 'match "no matching pattern" v)))
|
(begin
|
||||||
|
(match-error v)
|
||||||
|
#f))
|
||||||
;; named failure continuation
|
;; named failure continuation
|
||||||
((match-next v g+s (pat (=> failure) . body) . rest)
|
((match-next v g+s (pat (=> failure) . body) . rest)
|
||||||
(let ((failure (lambda () (match-next v g+s . rest))))
|
(let ((failure (lambda () (match-next v g+s . rest))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue