[plt-dev] syntax-case error messages

From: Jon Rafkind (rafkind at cs.utah.edu)
Date: Mon Mar 29 16:31:16 EDT 2010

FWIW, syntax-parse does a pretty good job with these same examples 
except for one case. Ryan, can you fix the 'bad syntax' error?

-> (syntax-parse #'1)
readline-input::199: syntax-parse: expected non-empty sequence of 
clauses in: (syntax-parse (syntax 1))
-> (syntax-parse #'1 2)
readline-input::236: ?: bad syntax in: 2
-> (syntax-parse #'1 [2])
readline-input::239: syntax-parse: expected non-empty clause body at: 
(2) in: (syntax-parse (syntax 1) (2))
-> (syntax-parse #'1 [2 2])
readline-input::278: ?: expected the literal 2 at: 1 in: 1

Interesting that syntax-parse also uses its own name in the error message.

On 03/29/2010 02:15 PM, Robby Findler wrote:
> I think putting "syntax-case:" at the front of the error message is
> the right thing (and that's a predictable thought, as I'm sure Matthew
> is thinking right now since it means that macros that use syntax-case
> to do their error checking will now have to do a better job). Maybe
> the presence of Ryan's syntax parse library means we can go with this
> nowadays, tho?
>
> Robby
>
> On Mon, Mar 29, 2010 at 2:06 PM, Jon Rafkind<rafkind at cs.utah.edu>  wrote:
>    
>> Attached is a small patch for syntax-case that makes some error messages
>> slightly more pleasant (at least to me).
>>
>> Old:
>>      
>>> (syntax-case #'1 ())
>>>        
>> bad syntax in: 1
>>      
>>> (syntax-case #'1 () 2)
>>>        
>> bad clause in: 2
>>      
>>> (syntax-case #'1 () [2])
>>>        
>> bad clause in: (2)
>>      
>>> (syntax-case #'1 () [2 2])
>>>        
>> bad syntax in: 1
>>
>> New:
>>      
>>> (syntax-case #'1 ())
>>>        
>> syntax-case was unable to match any patterns in: 1
>>      
>>> (syntax-case #'1 () 2)
>>>        
>> expected a list of clauses in: 2
>>      
>>> (syntax-case #'1 () [2])
>>>        
>> expected 2 or 3 expressions in a clause in: (2)
>>      
>>> (syntax-case #'1 () [2 2])
>>>        
>> syntax-case was unable to match any patterns in: 1
>>
>> There seems to be some disagreement with adding the name 'syntax-case' into
>> the error message. I could live without that I guess, but it would be nice
>> to change 'bad syntax' to something more informative, at least.
>>
>> _________________________________________________
>>   For list-related administrative tasks:
>>   http://list.cs.brown.edu/mailman/listinfo/plt-dev
>>
>>
>>      



Posted on the dev mailing list.