This commit is contained in:
Justin Ethier 2015-08-12 22:51:20 -04:00
parent 3608c2aeda
commit 7f0c89e2fd
2 changed files with 21 additions and 7 deletions

View file

@ -1,6 +1,18 @@
(define-library (libs lib2)
;(import (scheme base))
(export lib2-hello)
(import (scheme base))
(export lib2-hello or)
(begin
(define-syntax or
(er-macro-transformer
(lambda (expr rename compare)
(cond ((null? (cdr expr)) #f)
((null? (cddr expr)) (cadr expr))
(else
(list (rename 'let) (list (list (rename 'tmp) (cadr expr)))
(list (rename 'if) (rename 'tmp)
(rename 'tmp)
(cons (rename 'or) (cddr expr)))))))))
(define lib2-hello
"Hello from library #2")))

View file

@ -373,7 +373,8 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This step separates syntactic analysis from execution.
;; And environment is passed, but it is only used to expand macros.
;; - exp => Code to analyze
;; - env => Environment used to expand macros
;;
(define (analyze exp env)
(cond ((self-evaluating? exp)
@ -473,10 +474,11 @@
#f)))
(cond
((macro? var)
; look up symbol in env, and expand if it is a macro
; Adds some extra overhead into eval, which is not ideal. may need to
; reduce that overhead later...
(write (list 'JAE-DEBUG 'expanding exp)) ;; DEBUG-only
;; look up symbol in env, and expand if it is a macro
;; Adds some extra overhead into eval, which is not ideal. may need to
;; reduce that overhead later...
;;(write (list 'JAE-DEBUG 'expanding exp)) ;; DEBUG-only
;; TODO: need to use common rename/compare functions
;; instead of fudging them here. maybe keep common
;; functions in the macros module and hook into them???