diff options
author | Andy Wingo <wingo@pobox.com> | 2013-11-01 13:37:27 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-11-01 13:37:27 +0100 |
commit | 4a565538bd9fe196494b3a4d4c9918bf5a6ed029 (patch) | |
tree | 4ceb5b1734ecb433af459dfc9f09921ee7cf97e3 /module | |
parent | 58dee5b9e47c8186d894e847da0ff81aa9e9c073 (diff) | |
download | guile-4a565538bd9fe196494b3a4d4c9918bf5a6ed029.tar.gz |
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.
Diffstat (limited to 'module')
-rw-r--r-- | module/ice-9/match.upstream.scm | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/module/ice-9/match.upstream.scm b/module/ice-9/match.upstream.scm index 4609883d2..e32ba85fc 100644 --- a/module/ice-9/match.upstream.scm +++ b/module/ice-9/match.upstream.scm @@ -280,14 +280,19 @@ ;; clauses. `g+s' is a list of two elements, the get! and set! ;; expressions respectively. +(define (match-error v) + (error 'match "no matching pattern" v)) + (define-syntax match-next (syntax-rules (=>) ;; no more clauses, the match failed ((match-next v g+s) - ;; Here we wrap error within a double set of parentheses, so that - ;; the call to 'error' won't be in tail position. This allows the - ;; backtrace to show the source location of the failing match form. - ((error 'match "no matching pattern" v))) + ;; Here we call match-error in non-tail context, so that the + ;; backtrace can show the source location of the failing match + ;; form. + (begin + (match-error v) + #f)) ;; named failure continuation ((match-next v g+s (pat (=> failure) . body) . rest) (let ((failure (lambda () (match-next v g+s . rest)))) |