|
From: | Zelphir Kaltstahl |
Subject: | Re: Macro for replacing a placeholder in an expression |
Date: | Thu, 28 Jul 2022 11:26:33 +0000 |
On 7/28/22 11:48, Maxime Devos wrote:
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.
Yep, that is the case I meant : )
Hm OK, thanks for that! Well, it is in a repository of guile-examples, so I guess I can let go of wanting to do it all with syntax-rules.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: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.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?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:https://docs.scheme.org/surveys/syntax-definitions/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: http://code.call-cc.org/legacy-eggs/3/syntax-case.html,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.
Greetings, MaximeThank you again for your help and explanations! Things are much clearer now! Best regards,Zelphir
-- repositories:https://notabug.org/ZelphirKaltstahl
[Prev in Thread] | Current Thread | [Next in Thread] |