[Top][All Lists]

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

Re: Macro for replacing a placeholder in an expression

From: Maxime Devos
Subject: Re: Macro for replacing a placeholder in an expression
Date: Thu, 28 Jul 2022 11:48:58 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 28-07-2022 10:39, Zelphir Kaltstahl wrote:
I aimed to do everything with syntax-rules, as the simplest means, but when writing the code I have, I hit the snag, that one could not have multiple ellipses at the same level of nesting in the patterns.

IIUC, you mean:

(syntax-rules ()
  ((foo x ... y ...) [the replacement]))

? If so, such a construct is ambigious.

After some thinking I found the solution to build up a temporary list, which then is of course 1 deeper level of nesting, where I could then use ellipses again. I felt quite clever doing that trick. Maybe I could implement a syntax-map using that trick and then use syntax-map in my macro instead. I have a question regarding syntax-case:

If I use it, does my code become less portable to other Schemes?

And regarding syntax-rules:

How portable are macros, which exclusively use syntax-rules?

Everything that supports syntax-case most likely supports syntax-rules too, as syntax-rules can easily be defined in terms of syntax-case, so syntax-rules is at least as portable as syntax-case.

syntax-rules and syntax-case are pretty standard (it's in the R6RS), so I expect them to be available in recent-ish non-minimalistic Schemes.

However, some Schemes (likely Schemes that predate the R6RS, or in Schemes that try new things out), use other syntax systems.

Anyway, I've found a table:

Looks like syntax-rules is supported by all the tested systems. syntax-case is less supported, but among the 'low-level' macro systems it has the highest support.  It's a bit out-of-date though, syntax-case is supported for Chicken:,

Decide for yourself of course, but I don't think going for maximal portability is worth the effort here of something making things work with syntax-rules.


Thank you again for your help and explanations! Things are much clearer now!

Best regards,

Attachment: OpenPGP_0x49E3EE22191725EE.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]