[plt-dev] syntax-case error messages

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Mon Mar 29 22:36:22 EDT 2010

On Mon, Mar 29, 2010 at 6:33 PM, Matthias Felleisen
<matthias at ccs.neu.edu> wrote:
> On Mar 29, 2010, at 7:18 PM, Jay McCarthy wrote:
>> I believe that you've thought about this more than me.
> I am not sure but I sure had a head-start on you. Plus it is my distinct impression that everyone who starts with Lisp-y languages goes through most of the learning process that the "Lisp community" has gone through. (It's kind of like in biology.) For the purpose of 'syntax discussions', I do count us all as Lispers.
> So here we go. Syntax should be as dynamic as possible for the implementor of language extensions and as static as possible for users. That's especially true for the majority of programmers who write no macros or only simplistic macros.

I think what you're saying here is that you want a gentle ramp where
you can go from simple macros that have bad error messages up to fancy
ones that have good error messages. And I completely agree, iiuc.

> What does this mean? When the average programmer uses the language and its syntactic libraries, there should be no distinction. When something goes wrong with the syntax, report it in terms of the 'what' of the syntax not in terms of how the macro failed. Just imagine you'd get syntax error message from your Java compiler in terms of the parsing technology used, not in terms of the grammar parsed. You'd never ever touch the language again. I think this applies to our syntax world too. That's what I mean with 'static'. Then again, I have recanted on my belief that 'static syntax' means no dynamics for the syntax implementor. I now do use three levels of files to implement my syntactic extension (mostly world) so that I do get single point of control and usable syntax for beginning students.

Yes, I agree with this too: if the error messages are poor, you'll
stay away from the language.

But I don't see how this suggests that the error message "bad syntax"
is better than the error message "the syntax-case on line X didn't
have a matching case". To the naive programmer, they have equivalent
amounts of information (ie, nearly none). To the programmer that
implemented the macro (or macros) in question, the latter one has a
lot more information and thus is preferable.

I think your argument goes along the lines that "usually when we get a
'bad syntax' error message, that message is actually accurate and the
source location is pointing to the right place". And I think Matthew
is also saying that and even going one step further to say that
programmers are programming to the current syntax-case implementation
and explicitly avoid writing the [else (raise-syntax-error #f "bad
syntax" stx)] clause because they know that it is there.

This hypothesis is testable, right? We can find all of the uses of
syntax-case that don't have a default clause and see if they actually
do have the right error message or if they get the wrong thing, right?

> (In the end it may all boil down to my POPL lecture: Errors Matter.)

(Amen to that.)


Posted on the dev mailing list.