Let's consider a hypothetical example to understand the problem better. The user invents a new language called my-lang with keywords foo and mumble, and a variant of syntax-case called my-syntax-case. The problem has to do with the fact that the definition of the my-syntax-case macro introduces foo and mumble into its output (because invocations of my-syntax-case don't have to mention the keywords). So they get fresh marks, which distinguish them from the original foo and mumble. The solution is to cancel the fresh marks with syntax-local-introduce.
I won't reproduce the entire corrected macro, but here's the relevant portion of the second of the two cases (the simpler one, where there is no parent language):
Also, I should point out that it wasn't necessary to require at least one clause in the syntax-case variant, so I've corrected that, too.————
;; define the new language-specific syntax-case variant
(define-syntax (case stx)
(syntax-case stx ()
[(_ stx-exp (extra-kw (... ...)) clause (... ...))
(with-syntax ([(k (... ...))
(map syntax-local-introduce
(syntax->list #'(kw ...)))])
(syntax-case stx-exp (k (... ...) extra-kw (... ...))
clause (... ...)))]))
————
No comments:
Post a Comment