From 133e62278bc80778a34f1ec1fdded5ec0bfb6b5e Mon Sep 17 00:00:00 2001 From: Tim Vaughan Date: Fri, 28 Apr 2017 23:08:54 +1200 Subject: [PATCH] Improved let macro hygiene. --- README.md | 2 +- src/scheme-library.scm | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 974db98..2f78b7e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Scheme](https://github.com/petermichaux/bootstrap-scheme) (as described in [this wonderful series of blog posts](http://peter.michaux.ca/articles/scheme-from-scratch-introduction)) from C to forth, but also includes variadic compound function support, mark-sweep -garbage collection, quasiquotation, and a very basic (non-hygenic) macro +garbage collection, quasiquotation, and a basic (non-hygienic) macro system. In future, I plan to also implement a more complete numerical tower to bring it closer to diff --git a/src/scheme-library.scm b/src/scheme-library.scm index fb76f3a..73e8a4e 100644 --- a/src/scheme-library.scm +++ b/src/scheme-library.scm @@ -239,19 +239,9 @@ ; let -(define (let-vars args) - (if (null? args) - '() - (cons (caar args) (let-vars (cdr args))))) - -(define (let-inits args) - (if (null? args) - '() - (cons (cadar args) (let-inits (cdr args))))) - (define-macro (let args . body) - `((lambda ,(let-vars args) - ,@body) ,@(let-inits args))) + `((lambda ,(map (lambda (x) (car x)) args) + ,@body) ,@(map (lambda (x) (cadr x)) args))) ; while -- 2.20.1