Added a simplistic form of renaming

This commit is contained in:
Justin Ethier 2015-09-01 21:56:06 -04:00
parent 0578c4963a
commit ee8b5eeb65

View file

@ -266,31 +266,31 @@
((lambda (renames) ((lambda (renames)
(lambda (identifier) (lambda (identifier)
((lambda (cell) ((lambda (cell)
; (if cell (if cell
; (cdr cell) (cdr cell)
; ((lambda (name) ((lambda (name)
; (set! renames (cons (cons identifier name) renames)) (set! renames (cons (cons identifier name) renames))
; name) name)
; (let ((val (env:lookup identifier mac-env 'not-defined))) (let ((val (env:lookup identifier mac-env 'not-defined)))
; (cond (cond
; ((eq? val 'not-defined) ((or (not (tagged-list? 'macro val)) ;; TODO: For now only rename macros, but should support anything
; identifier) (eq? val 'not-defined))
; (else identifier)
; (let ((renamed (gensym identifier))) (else
; (env:define-variable! renamed val mac-env) (let ((renamed (gensym identifier)))
; renamed)))) (env:define-variable! renamed val mac-env)
; ; renamed))))
; ;(gensym identifier) ;
; ; gensym not good enough, need to also preserve ref trans. ;(gensym identifier)
; ; also note that an identifier can be an object, it does not ; gensym not good enough, need to also preserve ref trans.
; ; just have to be a symbol. although, of course, the rest ; also note that an identifier can be an object, it does not
; ; of the code needs to be able to handle identifiers in ; just have to be a symbol. although, of course, the rest
; ; forms other than symbols, if that is done. ; of the code needs to be able to handle identifiers in
; ; ; forms other than symbols, if that is done.
; ;(make-syntactic-closure mac-env '() identifier) ;
; ))) ;(make-syntactic-closure mac-env '() identifier)
identifier) )))
(assq identifier renames)) (assq identifier renames))
)) ))
;; TODO: For now, do not allow renaming of special form symbols to ;; TODO: For now, do not allow renaming of special form symbols to