suggestion: a shorter convenience form Per Bothner (22 Jun 2006 19:42 UTC)
Re: suggestion: a shorter convenience form Jens Axel Søgaard (25 Jun 2006 08:14 UTC)
Re: suggestion: a shorter convenience form Per Bothner (25 Jun 2006 14:27 UTC)
Re: suggestion: a shorter convenience form Jens Axel Søgaard (25 Jun 2006 15:49 UTC)
Re: suggestion: a shorter convenience form Per Bothner (26 Jun 2006 23:56 UTC)
Re: suggestion: a shorter convenience form Jens Axel Søgaard (27 Jun 2006 09:00 UTC)
Re: suggestion: a shorter convenience form Per Bothner (27 Jun 2006 14:55 UTC)

Re: suggestion: a shorter convenience form Jens Axel Søgaard 26 Jun 2006 08:59 UTC

Per Bothner skrev:
>
>> Consider Kent's implementation of cond in the reference
>> implementation using the common extension:
>>
>>   (define-syntax (cond x)
>>     (syntax-case x ()
>>       [(_ c1 c2 ...)
>  > ...
>>                 [_ (syntax-error x)]))]))]))
>>
>> With define-syntax-case (at least if I understand you correctly)
>> it becomes:
>>
>> (define-syntax-case cond ()
>>   (x (syntax-case x ()
>>       [(_ c1 c2 ...)
>  >        ...
>
> You could do that.  But since syntax-error is not in the specification,
> I'm not sure it is relevant.  If you leave out the syntax-error call,
> you get a worthwhile simplification:
>
> (define-syntax-case cond ()
>   ((_ c1 c2 ...) ...))

My point was that

     Refering to the original piece of syntax is often neccessary in
     order to give error messages in terms of user written syntax.

so in that context it is relevant.

I expect raise-syntax-error to be in the exception library. The lack
of precise error reporting from syntax-rules macros has for me been
the major reason to prefer syntax-case macros - even for small and
otherwise simple macros.

For that matter I'd like a portable way to work with source location
information - including a read-syntax form that unlike read keeps
the source location information.

> Note also that if you *do* want syntax-error, it might be better to
> report error location more specifically that the entire cond.

For misuses like (cond) and (cond 1) it makes sense to report the
entire macro call.

--
Jens Axel Søgaard