inline 'with' macro

This commit is contained in:
Yuichi Nishiwaki 2014-08-03 14:18:41 +09:00
parent e795b4a75a
commit a2fc679fab
1 changed files with 5 additions and 18 deletions

View File

@ -362,18 +362,6 @@
(import (scheme base) (import (scheme base)
(picrin macro)) (picrin macro))
(define-syntax with
(ir-macro-transformer
(lambda (form inject compare)
(let ((before (car (cdr form)))
(after (car (cdr (cdr form))))
(body (cdr (cdr (cdr form)))))
`(begin
(,before)
(let ((result (begin ,@body)))
(,after)
result))))))
(define-syntax parameterize (define-syntax parameterize
(ir-macro-transformer (ir-macro-transformer
(lambda (form inject compare) (lambda (form inject compare)
@ -381,12 +369,11 @@
(body (cdr (cdr form)))) (body (cdr (cdr form))))
(let ((vars (map car formal)) (let ((vars (map car formal))
(vals (map cadr formal))) (vals (map cadr formal)))
`(with `(begin
(lambda () ,@(map (lambda (var val) `(parameter-push! ,var ,val)) vars vals)
,@(map (lambda (var val) `(parameter-push! ,var ,val)) vars vals)) (let ((result (begin ,@body)))
(lambda () ,@(map (lambda (var) `(parameter-pop! ,var)) vars)
,@(map (lambda (var) `(parameter-pop! ,var)) vars)) result)))))))
,@body))))))
(export parameterize)) (export parameterize))