Re: Identifier syntax, and using macros with call/kw Marc Nieper-WiÃkirchen 07 Oct 2020 07:29 UTC
Am Di., 6. Okt. 2020 um 22:20 Uhr schrieb John Cowan <email@example.com>: > On Tue, Mar 3, 2020 at 5:12 AM Marc Nieper-Wißkirchen <firstname.lastname@example.org> wrote: > >> I'm glad that I could help. What I don't know, though, is why `syntax-rules' wasn't extended in the same way (in the way I used it) by R6RS, in particular because `syntax-rules' is just a trivial wrapper around `syntax-case'. > > > (Looking backward to read discussions about identifier-syntax) As we have also spoken about code-walking macros, let me put on record that Alex's point against identifier syntax he made when R6RS was ratified was misguided. His argument was based on code-walking macros but we have already seen that robust code-walking macros do not exist regardless of identifier syntax. (Au contraire, identifier syntax can obviate the need for some broken code walking macros. This, by the way, was already noted by Kent Dybvig on the SRFI 93 mailing list.) > I think the answer is the influence of Racket on R6RS. Racketeers, it seems, deprecate syntax-rules: they either use (define-syntax-rule pattern template), or they go to syntax-case. Supposedly this is due to better error checking possible with procedural code, although my answer would be to improve built-in error checking for syntax-case. You mean "syntax-rules" as for the last word? In the view of portability, deprecating syntax-rules doesn't seem to be like the best idea. It would be nice to see an example where good error checking is impossible even when using such macro libraries like SRFI 148. As an extension to syntax-rules, one may also want to allow the syntax-case fenders (I think Chez has this extension in non-strict-R6RS mode.) This way, I can write: (define-syntax let (syntax-rules () ((let ((var init) ...) . body) ---) ((let loop ((var init) ...) . body) (identifier? #'loop) (letrec loop ---)) ((let x ((var init) ...) . body) (syntax-error "the label of a named let has to be an identifier" x)) ---)) This is, of course, not R7RS-small but can be helpful if you want to/need to insert a few procedural checks but would otherwise like to continue writing syntax-rules macros.