unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Zelphir Kaltstahl <zelphirkaltstahl@posteo.de>
To: Maxime Devos <maximedevos@telenet.be>
Cc: Guile User <guile-user@gnu.org>
Subject: Re: Macro for replacing a placeholder in an expression
Date: Thu, 28 Jul 2022 11:26:33 +0000	[thread overview]
Message-ID: <f18f88df-a7a4-a682-d0ee-1c44254f9272@posteo.de> (raw)
In-Reply-To: <6a1abc16-7b4d-9ce1-daeb-f908e72c8d4c@telenet.be>

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 : )


>> 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.
>
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.


>>>
>>> Greetings,
>>> Maxime
>>
>> Thank you again for your help and explanations! Things are much clearer now!
>>
>> Best regards,
>> Zelphir 

-- 
repositories:https://notabug.org/ZelphirKaltstahl


      reply	other threads:[~2022-07-28 11:26 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
2022-07-28 11:26       ` Zelphir Kaltstahl [this message]

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=f18f88df-a7a4-a682-d0ee-1c44254f9272@posteo.de \
    --to=zelphirkaltstahl@posteo.de \
    --cc=guile-user@gnu.org \
    --cc=maximedevos@telenet.be \
    /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).