Experimenting with using macro:expand

This commit is contained in:
Justin Ethier 2018-02-08 17:49:05 -05:00
parent acde9d9b30
commit cfe4c90b5c

View file

@ -573,10 +573,12 @@
(if (Cyc-macro? macro-op) (if (Cyc-macro? macro-op)
;; Compiled macro, call directly ;; Compiled macro, call directly
(let ((expanded (let ((expanded
(apply macro-op (macro:expand exp (list 'macro macro-op) a-env rename-env '())
(list (cons (car exp) (operands exp)) ;(apply macro-op
(Cyc-er-rename rename-env a-env '()) ; (list (cons (car exp) (operands exp))
(Cyc-er-compare? rename-env a-env))))) ; (Cyc-er-rename rename-env a-env '())
; (Cyc-er-compare? rename-env a-env)))
))
(display "/* ") (display "/* ")
(write `(DEBUG expand ,exp )) (write `(DEBUG expand ,exp ))
(newline) (newline)
@ -587,13 +589,14 @@
a-env a-env
rename-env)) rename-env))
;; Interpreted macro, build expression and eval ;; Interpreted macro, build expression and eval
(let* ((expr (cons macro-op (let* (;(expr (cons macro-op
(list (cons 'quote ; (list (cons 'quote
(list (cons (car exp) ; (list (cons (car exp)
(operands exp)))) ; (operands exp))))
(Cyc-er-rename rename-env a-env '()) ; (Cyc-er-rename rename-env a-env '())
(Cyc-er-compare? rename-env a-env)))) ; (Cyc-er-compare? rename-env a-env))))
(expanded (eval expr a-env)) ;; Expand macro ; (expanded (eval expr a-env)) ;; Expand macro
(expanded (macro:expand exp (list 'macro macro-op) a-env rename-env '()))
) )
(display "/* ") (display "/* ")
(write `(DEBUG expand ,exp)) (write `(DEBUG expand ,exp))