Commit 5e975c39 authored by James R. Wilcox's avatar James R. Wilcox
Browse files

finish begin macro in L24

parent 9324f6ad
......@@ -139,3 +139,39 @@
(let ((_ (+ 1 2)))
(let ((_ (print! 'world)))
(+ 2 3)))))
(define (nested-lets exprs)
(match exprs
((cons e nil) e)
((cons e exprs)
(list 'let (list (list '_ e))
(nested-lets exprs)))))
(define (begin-transformer pst)
(match pst
((cons 'begin exprs)
(nested-lets exprs))))
; (begin ) -- assume this doesn't happen
; (begin e) -> e
; (begin e1 e2) -> (let ((_ e1)) e2)
; (begin e1 e2 e3) -> (let ((_ e1)) (let ((_ e2)) e3))
(begin-transformer
(quote
(begin
(print! 'hello)
(+ 1 2)
(print! 'world)
(+ 2 3))))
(install-syntax-transformer! begin begin-transformer)
(define f
(lambda ()
(begin
(print! 'hello)
(+ 1 2)
(print! 'world)
(+ 2 3))))
(f)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment