Re: In favor of explicit argument
Marc Nieper-Wißkirchen 13 Aug 2020 08:04 UTC
Am Do., 13. Aug. 2020 um 03:53 Uhr schrieb John Cowan <xxxxxx@ccil.org>:
> Identifier macros aren't necessary. For example, to make <- work as shared auxiliary syntax, just bind it like this:
>
> (define-syntax <-
> (syntax-rules ()
> ((** head . tail)
> (syntax-error "invalid auxiliary syntax" head . tail))))
As I wrote above, in a Scheme supporting syntax parameters, this should be
(define-syntax-parameter <-
(syntax-rules ()
((** head . tail) ...)))
This allows to hygienically rebind the auxiliary syntax in some
sophisticated macros while it will still be recognized in its
auxiliary keyword meaning.
> Now (<- 1 2 3) will signal an expansion-time error, and (+ 0 <-) will too because an ordinary macro can't be used in operand position.
In a Scheme supporting Identifier macros, they can be used to improve
the error reporting:
(define-syntax-parameter <-
(identifier-syntax (syntax-error "invalid use of auxiliary syntax" '<-)))
In this case, both "(<- 1 2 3)" and (+ 0 <-)" will produce the same error.