[r6rs-discuss] [Formal] Trivial Enhancement of macros in v5.91: capture-syntax
On Nov 28, 2006, at 7:31 AM, Matthew Flatt wrote:
> Wrong. Your code works just fine with explicit phases.
>
> As is typical, no `for' declarations are necessary, mostly because
> `r6rs' exports into both run and expand phases
I apologize. If you don't mind me asking, would these two phases be
distinct or the same? (maybe it doesn't matter for this example, but
I still wonder.)
One more question if you don't mind, would the following work? (maybe
you don't want it, but I was re-factoring it and realized I didn't want
to regenerate the transformers every time you enter a new [un]trace-
region.
I'm curious.)
(library tracers-helpers
(export print-args)
(import r6rs)
(define print-args
(lambda (fml* act*)
(display "Lambda ")
(display fml*)
(display " : ")
(display act*)
(newline))))
(library tracers
(export trace-region untrace-region)
(import r6rs r6rs::syntax-case tracers-helpers)
(define trace-transformer
(lambda (stx)
(syntax-case stx ()
[(_ fml* b b* ...)
#'(lambda act*
(print-args 'fml* act*)
(apply (lambda fml* b b* ...) act*))])))
(define-syntax trace-region
(lambda (x)
(syntax-case x ()
[(kwd b b* ...)
(with-syntax ([L (datum->syntax #'kwd 'lambda)])
#'(let-syntax ([L trace-transformer])
b b* ...))])))
(define untrace-transformer
(lambda (stx)
(syntax-case stx ()
[(_ fml* b b* ...)
#'(lambda fml* b b* ...)])))
(define-syntax untrace-region
(lambda (x)
(syntax-case x ()
[(kwd b b* ...)
(with-syntax ([L (datum->syntax #'kwd 'lambda)])
#'(let-syntax ([L untrace-transformer])
b b* ...))]))))
Aziz,,,
Received on Tue Nov 28 2006 - 08:21:16 UTC
This archive was generated by hypermail 2.3.0
: Wed Oct 23 2024 - 09:15:00 UTC