From: Tim Vaughan Date: Fri, 28 Apr 2017 11:08:54 +0000 (+1200) Subject: Improved let macro hygiene. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=scheme.forth.jl.git;a=commitdiff_plain;h=133e62278bc80778a34f1ec1fdded5ec0bfb6b5e Improved let macro hygiene. --- 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