WIP, trying to understand why macro is failing

This commit is contained in:
Justin Ethier 2015-08-04 23:04:39 -04:00
parent 5b997fe0a8
commit 8c3d5347ab
2 changed files with 19 additions and 6 deletions

View file

@ -914,7 +914,7 @@
;; return some value such as #t or nil as a placeholder, since the ;; return some value such as #t or nil as a placeholder, since the
;; define-syntax form would not be carried forward in the compiled code ;; define-syntax form would not be carried forward in the compiled code
((define-syntax? exp) ;; TODO: not good enough, should do error checking, and make sure list is big enough for cadr ((define-syntax? exp) ;; TODO: not good enough, should do error checking, and make sure list is big enough for cadr
(trace:info `(define-syntax ,exp)) ;(trace:info `(define-syntax ,exp))
(let* ((name (cadr exp)) (let* ((name (cadr exp))
(trans (caddr exp)) (trans (caddr exp))
(body (cadr trans))) (body (cadr trans)))

View file

@ -1,11 +1,24 @@
(import (scheme base) (import (scheme base)
(scheme write)) (scheme write))
;(define-syntax test
; (er-macro-transformer
; (lambda (expr rename compare)
; `((lambda ()
; (write "testing")
; (write (quote ,(cdr expr))))))))
;
; WTF is the macro unable to be evaluated when the same code works as part of *defined-macros*???
;
(define-syntax test (define-syntax test
(er-macro-transformer (er-macro-transformer
(lambda (expr rename compare) (lambda (expr rename compare)
(write "testing") (cond ((null? (cdr expr)))
(write expr)))) ((null? (cddr expr)) (cadr expr))
(else (list (rename 'if) (cadr expr)
(cons (rename 'and) (cddr expr))
#f))))))
(test 1 2 3) (test 1 2 3)
(test 'done) ;(test 'done)
'done