(define test-environment
(the-environment))
+(define genv
+ (runtime-environment->syntactic test-environment))
+
+(define (grename form)
+ (close-syntax form genv))
+
(define-syntax outer
- (sc-macro-transformer
- (lambda (form use-env)
+ (er-macro-transformer
+ (lambda (form rename compare)
+ (declare (ignore compare))
(syntax-check '(_ identifier) form)
- (let* ((raw (cadr form))
- (closed (close-syntax raw use-env)))
- `(define-syntax ,(close-syntax 'inner use-env)
- (sc-macro-transformer
- (lambda (form use-env)
- (syntax-check '(_) form)
- `(,(quote-identifier ,raw)
- ,(quote ,raw)
- ,(quote-identifier ,closed)
- ,(quote ,closed)))))))))
+ (let ((id (cadr form)))
+ `(,(rename 'define-syntax) inner
+ (,(rename 'sc-macro-transformer)
+ (,(rename 'lambda) (form use-env)
+ (,(rename 'list)
+ 'list
+ (,(rename 'grename) (,(rename 'quote) ,id))
+ (,(rename 'grename) (,(rename 'quote-identifier) ,id))
+ ))))))))
;; A fairly complicated test that shows how quote-identifier works,
;; how it's different from quote, and that weird binding combinations
'(let ((car 13))
(outer car)
(let ((car 15))
- (car (inner))))))
+ (cons car (inner))))))
(assert-equal (unsyntax (syntax expr test-environment))
'(let ((.car.1 13))
(let ((.car.2 15))
- (.car.2 (car car .car.1 car))))))))
\ No newline at end of file
+ (cons .car.2 (list car .car.1))))))))
\ No newline at end of file