[racket] confusing error with keywords

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Wed Nov 17 16:20:57 EST 2010

On Wed, Nov 17, 2010 at 3:15 PM, Matthias Felleisen
<matthias at ccs.neu.edu> wrote:
>
> Isn't the true problem that we pretend uniformity of syntax and values? In this case, we specifically pretend that functions and syntaxes may consume the same kind of keyword-labeled arguments.

I don't think that this second sentence is right. Keywords are
generally used in a more flexible manner in syntax than in function
applications (ie you can have a keyword with no argument at all
instead of having to do something like stick a boolean on it).

> Except that when you make a small mistake, the brittleness of this arrangement shows up and you get WEIRD ERROR MESSAGES.

I think that here Jon has misspelled a macro keyword so he gets the
implicit application keyword stuck in there. That's the source of the
bad error message, IMO.

The right error here should be something like "I don't know what
define-struct/contract is" but the #%app is doing its keyword-well
formededness checks before the free variable check happens.

> When systems work, nobody cares how they work. It's errors that make people notice, and errors happen all the time.

Well, yeah....

Robby

>
>
> On Nov 17, 2010, at 3:55 PM, Jon Rafkind wrote:
>
>> I found this error message confusing. The problem is I forgot to require
>> racket/contract.
>>
>> #lang racket/base
>>
>> (define-struct/contract foo ([a any/c]) #:transparent)
>>
>>>
>> application: missing argument expression after keyword at: #:transparent
>> in: (#%app define-struct/contract foo ((a any/c)) #:transparent)
>>
>> I was confused because I thought I had a (require racket/contract)
>> somewhere but apparently I didn't. I don't know if anything at all can
>> be done about it..
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://lists.racket-lang.org/listinfo/users
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>


Posted on the users mailing list.