I seem to remember that in R7RS, an underscore matches anything, which
is not entirely compatible with R5RS, where you could actually use an
underscore as a variable name.

That seems correct. I can find the underscore rule in neither R5RS nor SRFI 46, but it is present in R6RS and R7RS.

Besides that one nitpick, I'd be fine with copying it over to core.

Here's the diff (with `diff -uw`, ignoring whitespace differences): https://misc.lassi.io/2023/chicken-synrules.diff

It looks like the changes are light.

Of particular note is that the R7RS code adds this:

+   ;; R7RS support: underscore matches anything
+   (define (underscore? x)
+     (c x (r '_)))

If you wish to support the R5RS semantics where underscore isn't special, this procedure could check some kind of state variable saying which flavor of syntax-rules to use. `underscore?` could always return #f unless the R7RS version is in use.

Reply via email to