unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: Zelphir Kaltstahl <zelphirkaltstahl@posteo.de>
Cc: Guile User <guile-user@gnu.org>
Subject: Re: Macro for replacing a placeholder in an expression
Date: Thu, 28 Jul 2022 11:48:58 +0200	[thread overview]
Message-ID: <6a1abc16-7b4d-9ce1-daeb-f908e72c8d4c@telenet.be> (raw)
In-Reply-To: <61f3c2d2-78ec-cec6-5933-f0f8a5bc3aba@posteo.de>


[-- Attachment #1.1.1: Type: text/plain, Size: 2113 bytes --]


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:

> 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,
>> Maxime
>
> Thank you again for your help and explanations! Things are much 
> clearer now!
>
> Best regards,
> Zelphir 


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

  reply	other threads:[~2022-07-28  9:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-27 23:57 Macro for replacing a placeholder in an expression Zelphir Kaltstahl
2022-07-28  0:55 ` Maxime Devos
2022-07-28 10:23   ` Zelphir Kaltstahl
2022-07-28 10:28     ` Maxime Devos
2022-07-30 15:42     ` Zelphir Kaltstahl
2022-07-30 20:44       ` Maxime Devos
2022-07-30 21:10         ` Maxime Devos
2022-07-30 21:13       ` Maxime Devos
2022-08-05  9:42         ` Linus Björnstam
2022-08-06 14:28           ` Zelphir Kaltstahl
2022-07-28  1:04 ` Maxime Devos
2022-07-28  8:39   ` Zelphir Kaltstahl
2022-07-28  9:48     ` Maxime Devos [this message]
2022-07-28 11:26       ` Zelphir Kaltstahl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a1abc16-7b4d-9ce1-daeb-f908e72c8d4c@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=guile-user@gnu.org \
    --cc=zelphirkaltstahl@posteo.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).