From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zelphir Kaltstahl Newsgroups: gmane.lisp.guile.user Subject: Re: Macro for replacing a placeholder in an expression Date: Thu, 28 Jul 2022 11:26:33 +0000 Message-ID: References: <80083c86-19b0-7537-be70-f763bd5b390f@posteo.de> <0c9ca13b-5cda-b575-4645-2040bb30ea53@telenet.be> <61f3c2d2-78ec-cec6-5933-f0f8a5bc3aba@posteo.de> <6a1abc16-7b4d-9ce1-daeb-f908e72c8d4c@telenet.be> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7531"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Guile User To: Maxime Devos Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Thu Jul 28 13:27:05 2022 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oH1fU-0001oa-T8 for guile-user@m.gmane-mx.org; Thu, 28 Jul 2022 13:27:04 +0200 Original-Received: from localhost ([::1]:57260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH1fT-0004uA-Os for guile-user@m.gmane-mx.org; Thu, 28 Jul 2022 07:27:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH1f7-0004u1-1o for guile-user@gnu.org; Thu, 28 Jul 2022 07:26:41 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:37099) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH1f4-0001eZ-BT for guile-user@gnu.org; Thu, 28 Jul 2022 07:26:40 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 4A9BB240026 for ; Thu, 28 Jul 2022 13:26:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1659007596; bh=c477ryLJEGUHqqsWxUcXc/8GUUsxswfORo8dtApQdzI=; h=Date:Subject:To:Cc:From:From; b=dG2xutETg3kO6wf7/Syr0oX6g2cIOjGaA3MI+cLXkJPKOfz+4ldi0gUqONMNwfZ8Z TNMSMLUR92r0mwI/mnUVpD4jD5yG0v6gUcjgmVy+RpfP/9N3avPaxuTtKoFoMOo9us rYp3WOWWwUW4cpdAMwVUlQiUh0JVx0z1eWVcGT44+7VRcYpjkzchgik/qX/UtVeAzZ wPiPWKf5JJOZlLzTo6x6m9OfRV6cZR59KBK314YW4IPWMGQV3gN44tie5JuZt73PAZ XHog85HKYy8n5mpKkFaTnRG82R+MF7m3DH1DmgxwLfr750du1lF65XUnJBiV7zBhGK Ovlc3F6FHoelA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4LtpJB3WJlz6trS; Thu, 28 Jul 2022 13:26:34 +0200 (CEST) Content-Language: en-US In-Reply-To: <6a1abc16-7b4d-9ce1-daeb-f908e72c8d4c@telenet.be> Received-SPF: pass client-ip=185.67.36.65; envelope-from=zelphirkaltstahl@posteo.de; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:18461 Archived-At: 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