[plt-scheme] Macrology

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Thu Jun 14 14:33:13 EDT 2007

Jay McCarthy wrote:

> Is kernel-syntax-case broken? Am I broken? Should I just be using
> syntax-case*? If so, what identifer=? should I use to really match all
> expanded code.

Since the expression in (define-syntaxes (v ...) ve) is to
be evaluated in the transformer environment, you need to
switch from #f to #t. Introducing a parameter to keep
track of this seems to be the least intrusive solution.

(module test mzscheme
   (provide test)
   (require (lib "kerncase.ss" "syntax")
            (lib "list.ss"))

   (define (test)
     (define t? (make-parameter #f))
     (define (loop stx)
       (kernel-syntax-case stx (t?)
         [(begin e ...)
          (andmap loop (syntax->list #'(e ...)))]
         [(define-values (v ...) ve)
          (loop #'ve)]
         [(define-syntaxes (v ...) ve)
          (parameterize ([t? #t])
            (loop #'ve))]
         [(let-values ([(v ...) ve] ...) be ...)
         [(quote datum)
          (raise-syntax-error 'anormal "Dropped through:" stx)]))

     (loop (expand (syntax (define-struct posn (x y)))))
     (loop (expand (syntax ()))))


(require (lib "syntax-browser.ss" "macro-debugger"))
(browse-syntax (expand (syntax (define-struct posn (x y)))))

Jens Axel Søgaard

Posted on the users mailing list.