[racket] confusing error with keywords
Syntax has dependencies. In (X . ARGS), the interpretation of ARGS
depends on X. So X should be validated* before ARGS is interpreted. Most
macros either obey this principle automatically or have relatively
benign violations**, but #%app is a bit special.
I agree with Carl.
Ryan
* Probably X doesn't need to be fully validated, just enough to justify
the decisions based on it.
** Here's a benign violation:
(rwhen body condition) => (when condition body)
If both body and condition contain syntax errors, the error in condition
is reported first, surprisingly. A slightly better way to write the
macro would be this:
(rwhen body condition) => (let ([c (lambda () condition)])
(when (c) body))
Expansion happens in the expected order, and the compiler can fix up the
code afterwards.
On 11/17/2010 02:19 PM, Matthias Felleisen wrote:
>
> That's a fix for the symptom, and it occurred to me too.
> Let's try to look at the large picture, too, instead of
> just looking for bandaids for symptoms.
>
>
> On Nov 17, 2010, at 4:17 PM, Carl Eastlund wrote:
>
>> Personally I would like to see the error here be that
>> define-struct/contract is not bound. If the order of either top level
>> expansion or #%app worked slightly differently, we could get that
>> error first and all would be clear.
>>
>> Carl Eastlund
>>
>> On Wed, Nov 17, 2010 at 4: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. Except that when you make a small mistake, the brittleness of this arrangement shows up and you get WEIRD ERROR MESSAGES.
>>>
>>> When systems work, nobody cares how they work. It's errors that make people notice, and errors happen all the time.
>>>
>>>
>>>
>>> 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