[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: suggestion: a shorter convenience form

This page is part of the web mail archives of SRFI 93 from before July 7th, 2015. The new archives for SRFI 93 contain all messages, not just those from before July 7th, 2015.



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