add let*.

This commit is contained in:
Jan Nieuwenhuizen 2016-07-09 20:12:49 +02:00
parent 6d5811bb98
commit 6b54eb9d76
2 changed files with 25 additions and 0 deletions

12
scm.mes
View file

@ -80,3 +80,15 @@ EOF
(define-macro (let bindings . body) (define-macro (let bindings . body)
(cons (cons 'lambda (cons (split-params bindings '()) body)) (cons (cons 'lambda (cons (split-params bindings '()) body))
(split-values bindings '()))) (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)))))
(define-macro (let* bindings . body)
(expand-let* bindings body))

View file

@ -82,4 +82,17 @@
`(aa bb ,c) `(aa bb ,c)
(display `(pp qq ,c)) (display `(pp qq ,c))
(newline) (newline)
(display
(let* ((aa 2)
(bb (+ aa 3))
#! boo !#
;;(bb 4)
)
(display 'allo:)
bb))
(newline)
(display 'let*-dun)
(newline)
'() '()