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

From: Marijn (hkBst at gentoo.org)
Date: Mon Feb 13 05:05:47 EST 2012

Hash: SHA1

On 10-02-12 23:38, John Clements wrote:
> A user on stackoverflow had a question about this code:
> (define list-sum-odd (lambda (list) (cond ((null? list) 0) ((odd?
> (car list)) (+ (car list) (list-sum-odd (cdr list)))) (list-sum-odd
> (cdr list)))))
> (list-sum-odd '(3 4 5))
> ... which signalled an error. In #lang racket, you get
> "+: expects type <number> as 2nd argument, given: '(5); other
> arguments were: 3"
> ... which is the right error for #lang racket. The response showed
> him that he'd forgotten the "else" in his last clause.
> "Ho Ho!" thought I. "Beginner Student Racket will give a much
> better error message." Actually, though, the error message was much
> worse: 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

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

Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/


Posted on the dev mailing list.