[racket-dev] very unhelpful beginner language error message, possible fix proposed

From: Stephen Bloch (bloch at adelphi.edu)
Date: Mon Feb 13 08:11:25 EST 2012

On Feb 13, 2012, at 5:05 AM, Marijn wrote:

>> ... it highlighted the id "list-sum-odd" in what should have
>> been the 'else' case, and wrote:
>> "list-sum-odd: expected a function call, but there is no open
>> parenthesis before this function"
>> ... which is really terrible, because there *IS* a parenthesis
>> right before the function name.
> How about changing the message such that it complains about a shortage
> of parentheses without stating that there are none?
> - - expected a function call, but there is an open parenthesis missing
> before this function name

Doesn't help much: as any student can see, there IS an open parenthesis before this function name.

> Or maybe formulate it in a positive way to encourage the user to
> insert parentheses?
> - - expected a function call, but found a function name; to call it add
> surrounding parentheses

It's GOT surrounding parentheses.

The mistake the student made was at the "cond" level, not at the level of this function call, so the "right" error message has to say something about "cond", like

-- cond: each clause must be a question/answer pair enclosed in brackets.  You have two expressions that look like the "question" and the "answer", but you need another pair of brackets around the two of them.

It should be possible for the "cond" macro to detect this situation, at least in BSL, because the first element of what should be a cond-clause is a function name, and that's not a complete expression.  In ISLL, a function name can appear as an expression in its own right, but it still doesn't make sense as the first element of a cond-clause because a function name isn't a boolean: if it's defined, then it's non-null and therefore true, and if it's not, the student shouldn't be mentioning it at all.  Not until ASL does it become possible (albeit unlikely) that a function name could make sense as a condition.

Stephen Bloch
sbloch at adelphi.edu

Posted on the dev mailing list.