From b638d33e4b7e3e42744ca2da6b28207c21553d0b Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 16 Jul 2016 17:57:19 +0200 Subject: [PATCH] cleanup let, let*, letrec --- scm.mes | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/scm.mes b/scm.mes index 37bee77c..3074b093 100755 --- a/scm.mes +++ b/scm.mes @@ -63,17 +63,15 @@ (append values (cdar bindings) '()))))) (define-macro (let bindings . body) - (cons (cons 'lambda (cons (split-params bindings '()) body)) - (split-values bindings '()))) + `((lambda ,(split-params bindings '()) ,@body) + ,@(split-values bindings '()))) (define (expand-let* bindings body) (cond ((null? bindings) - (cons (cons 'lambda (cons '() body)) '())) - (#t - (cons - (cons 'lambda (cons (cons (caar bindings) '()) - (cons (expand-let* (cdr bindings) body) '()))) - (cdar bindings))))) + `((lambda () ,@body))) + (#t `((lambda (,(caar bindings)) + ,(expand-let* (cdr bindings) body)) + ,@(cdar bindings))))) (define-macro (let* bindings . body) (expand-let* bindings body)) @@ -110,7 +108,7 @@ (cons (cons 'set! (car bindings)) '())))))) (define-macro (letrec bindings . body) - (cons 'let (cons (unspecified-bindings bindings '()) - (append (letrec-setters bindings '()) - body))) ) + `(let ,(unspecified-bindings bindings '()) + ,@(letrec-setters bindings '()) + ,@body))