[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.

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 ...) ...))

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

Adding an extra binding form also adds to the cognitive load
for those learning the macro system. For the experienced
macro writer it hardly matters which is used.

I don't know.  Scheme API design has this bad tradition of
designing APIs for maximum verbosity of the common case.  call/cc is
another example, given that 90% of the time the argument is a
lambda expression, which makes code that can be hard to understand
even more difficult.
	--Per Bothner
per@xxxxxxxxxxx   http://per.bothner.com/