add named-let

This commit is contained in:
Yuichi Nishiwaki 2013-11-14 17:31:59 +09:00
parent e68c69ceb1
commit 62069af4f9
1 changed files with 17 additions and 3 deletions

View File

@ -137,10 +137,24 @@
(cons (f (car list))
(map f (cdr list)))))
;;; bootstrap
(define-macro (let bindings . body)
(if (symbol? bindings)
(begin
(define name bindings)
(set! bindings (car body))
(set! body (cdr body))
;; expanded form should be like below:
;; `(let ()
;; (define ,loop
;; (lambda (,@vars)
;; ,@body))
;; (,loop ,@vals))
(list 'let '()
(list 'define name
(cons 'lambda (cons (map car bindings) body)))
(cons name (map cadr bindings))))
(cons (cons 'lambda (cons (map car bindings) body))
(map cadr bindings)))
(map cadr bindings))))
(define-macro (cond . clauses)
(if (null? clauses)