[plt-scheme] more macro

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Aug 7 08:57:04 EDT 2006

At Mon, 07 Aug 2006 13:49:50 +0200, Jens Axel Søgaard wrote:
> The problem with
>    (syntax-case x ()
>      ((_ 'f e1 e2 ...) <template-using-'>))
> is that the pattern is equivalent to
>    (syntax-case x ()
>      ((_ (quote f) e1 e2 ...) <template-using-'>))
> which means that in <template-using-'> quote will be a pattern variable
> bound to whatever occured before f in the input syntax x. To be
> sure ' refers to a quote use
>    (syntax-case x (quote)
>      ((_ (quote f) e1 e2 ...) <template-using-'>))


> In your m2 the quote in 'x is not in a template, so I don't think
> it should be a problem in that particular macro. Unless ... Hmm.

A pattern binding is a binding, just like a `let' binding, but a
pattern binding can only be used legally inside a template.

I've made the error message more specific:

 quote: pattern variable cannot be used outside of a template at: quote
 in: (quote x)

[When the `syntax-case' macro was first written, we didn't have the
infrastructure to make the error message more specific than "syntax

I'm not sure why you didn't see an error message in v301.13; the
interaction suggests that the definition `m2' didn't take, somehow. In
any case, it should always have been an error.

At Mon, 7 Aug 2006 13:16:23 +0200 (CEST), Ivanyi Peter wrote:
> Another strange thing with macros, when I type this in DrScheme:
> (syntax-object->datum (expand #'(require (lib "list.ss"))))
> It expands to:
> (require (lib "list.ss"))
> Should not it expand to something with #%app and #%top and 
> #%datum, to the most basic form? What is preventing it?

`require' is a primitive form, just like `lambda' or `#%app'.


Posted on the users mailing list.