From 5b0da0948a567c8dc06cc6623443b784bb8aeb4b Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Wed, 20 Aug 2008 19:52:58 +0000 Subject: [PATCH] Fix or not to use continuations, and to use a success/failure flag instead. Fixed PR 9689. svn: r11360 --- collects/scheme/match/compiler.ss | 39 ++++++++++++++++--------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/collects/scheme/match/compiler.ss b/collects/scheme/match/compiler.ss index 1b44b510f5..7d29608569 100644 --- a/collects/scheme/match/compiler.ss +++ b/collects/scheme/match/compiler.ss @@ -205,27 +205,28 @@ #:when (for/and ([seen-var seen]) (not (free-identifier=? bv (car seen-var))))) bv)]) - (with-syntax ([(var ...) vars]) + (with-syntax ([(success? var ...) (append (generate-temporaries '(success?)) vars)]) ;; do the or matching, and bind the results to the appropriate ;; variables - #`(let/ec exit - (let ([esc* (lambda () (exit (#,esc)))]) - (let-values ([(var ...) - #,(compile* (list x) - (map (lambda (q) - (make-Row (list q) - #'(values var ...) - #f - seen)) - qs) - #'esc*)]) - ;; then compile the rest of the row - #,(compile* xs - (list (make-Row (cdr pats) - (Row-rhs row) - (Row-unmatch row) - (append (map cons vars vars) seen))) - esc))))))] + #`(let ([esc* (lambda () (values #f #,@(for/list ([v vars]) #'#f)))]) + (let-values ([(success? var ...) + #,(compile* (list x) + (map (lambda (q) + (make-Row (list q) + #'(values #t var ...) + #f + seen)) + qs) + #'esc*)]) + ;; then compile the rest of the row + (if success? + #,(compile* xs + (list (make-Row (cdr pats) + (Row-rhs row) + (Row-unmatch row) + (append (map cons vars vars) seen))) + esc) + (#,esc))))))] ;; the App rule [(App? first) ;; we only handle 1-row Apps atm - this is all the mixture rule should