[plt-scheme] match.ss performance
So, what should the expansion be? Two things come to mind (shown
below), but I have no idea which one is more efficient (or perhaps
there is a third?)
Also, what about `or' patterns? Should that use continuations, or maybe
just continuation-passing style with success and failure continuations?
(probably in mzscheme cps is far more efficient) How do you re-use
parts of overlapping ors? (or do you just assume that the overlapping
parts have been lifted out?)
Robby
(let ([fail (lambda () (match:error ...))])
(let ([x l])
(if (pair? x)
(let ([x2 (cdr x)])
(if (pair? x2)
(let ([x3 (cdr x2)])
(if (pair? x3)
(let ([x4 (cdr x3)])
(if (pair? x4)
(let ([x4 (cdr x4)])
(if (null? x4)
((lambda (a4 a3 a2 a1) l)
(car x4) (car x3) (car x2) (car x1))
(fail)))
(fail)))
(fail)))
(fail)))
(fail))))
(let ([fail (lambda () (match:error ...))])
(let ([x l])
(if (not (pair? x)) (fail))
(let ([x2 (cdr x)])
(if (not (pair? x2)) (fail))
(let ([x3 (cdr x2)])
(if (not (pair? x3)) (fail))
(let ([x4 (cdr x3)])
(if (not (pair? x4)) (fail))
(let ([x4 (cdr x4)])
(if (not (null? x4)) (fail))
((lambda (a4 a3 a2 a1) l)
(car x4) (car x3) (car x2) (car x1))))))))