[plt-dev] macro error messages

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Mar 29 17:19:50 EDT 2010

At Mon, 29 Mar 2010 15:06:00 -0600, Jon Rafkind wrote:
> Can these error messages be reviewed as well?
> 
> On 03/26/2010 03:55 PM, Jon Rafkind wrote:
> > Can this error message
> >
> >   illegal use of syntax
> >
> > be changed to
> >
> >   illegal application of a transformer. transformers must be functions 
> > that accept one argument.
> >
> > To reproduce this error use this code:
> >
> > (define-syntax (foo a b c) #'1)
> > (foo)
> >
> > There is only one change to be made in eval.c line ~6284

Like the suggested `syntax-case' change, I think this one assumes the
perspective of a macro implementor with a particular goal.

In general, an identifier bound with `define-syntax' doesn't have to be
bound to a transformer procedure. A non-transformer binding may be
intentional and useful, such as when a pattern variable is bound by
`syntax-case'.

In such cases, it's a good idea to make the binding also include a
transformer procedure (perhaps through `prop:procedure') and refine the
"illegal use of syntax" error message --- just like it's a good idea to
cover more cases in `syntax-case' or `syntax-parse' and give good error
messages. But if a programmer doesn't do that, then "bad syntax" or
"illegal use of syntax" is about all that can be said automatically.


> > Also I would like to change this error
> >
> >   identifier used out of context
> >
> > But I'm not exactly sure what to change it to.
> >
> > Reproduce it with:
> >
> > (define-syntax (foo stx)
> >   (let ([x 1])
> >     #'x))
> > (foo 2)
> >
> > compile: identifier used out of context in: x

I don't have ideas for that one, either.



Posted on the dev mailing list.