From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxime Devos Newsgroups: gmane.lisp.guile.user Subject: Re: Is it possible to expand syntax inside match? Date: Sun, 24 Oct 2021 19:48:01 +0000 Message-ID: <60fe167bfab829583b1ba6dca28c06b76fd41b9c.camel@telenet.be> References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11677"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.38.3-1 To: =?UTF-8?Q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB_?= =?UTF-8?Q?=D0=91=D0=B0=D1=85=D1=82=D0=B5=D1=80=D0=B5=D0=B2?= , guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Oct 24 21:48:23 2021 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 1mejTi-0002sV-VT for guile-user@m.gmane-mx.org; Sun, 24 Oct 2021 21:48:23 +0200 Original-Received: from localhost ([::1]:53718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mejTh-00073x-KP for guile-user@m.gmane-mx.org; Sun, 24 Oct 2021 15:48:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mejTV-00073X-GR for guile-user@gnu.org; Sun, 24 Oct 2021 15:48:09 -0400 Original-Received: from michel.telenet-ops.be ([2a02:1800:110:4::f00:18]:60106) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mejTT-00072W-3O for guile-user@gnu.org; Sun, 24 Oct 2021 15:48:09 -0400 Original-Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by michel.telenet-ops.be with bizsmtp id 9vo12600E4UW6Th06vo1Ch; Sun, 24 Oct 2021 21:48:01 +0200 In-Reply-To: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1635104881; bh=nLQpm+tKQ4/c9VbNwBKZ9gn/ASJsRw6xADXmIZTfCAo=; h=Subject:From:To:Date:In-Reply-To:References; b=q3gS8CIOqP8is/Ek4i6Fih/vLRQRftaRc2aP4DTivAFKP2IGy8e4xBoayKuvNwWAo yL21ESvSgnBwMWR9EaxXEfGN/FI2p0UQ7g2rI9u3/sS8jIpf3fkL55ZG4W9zEyRTpk eV/Y4PDIxkEBnNObYZEPJWD3wrIoqbKkLSYmVGrs8OOt7zuN+LpDTyS1FxtEqIDwXD AzrzYKObW7DOwzkU/ASCdTj0/sVzHQgX6YVD/zBJOomHQFwazrvVa4K4itxW/YB6NZ cAglqYFLTC5mdLxdXHarss1k1z8UG91vShmeErygGXlIrZKJ0riQGMyXrK6+3T1OKs mIkz09hgh95IQ== Received-SPF: pass client-ip=2a02:1800:110:4::f00:18; envelope-from=maximedevos@telenet.be; helo=michel.telenet-ops.be X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 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, FREEMAIL_FROM=0.001, FUZZY_XPILL=0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 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:17815 Archived-At: Михаил Бахтерев schreef op zo 24-10-2021 om 11:49 [+0500]: > Greetings! > > I wondering, if is it possible to implement something like > this? > > (define-syntax R (syntax-rules () ((_ r v l) #(red r v l)))) > (define-syntax B (syntax-rules () ((_ r v l) #(black r v l)))) > > (define red-black-set-balance >   (match-lambda >     ((or (B (R (R a x b) y c) z d) >          (B (R a x (R b y c)) z d) >          (B a x (R (R b y c) z d)) >          (B a x (R b y (R c z d)))) (R (B a x b) y (B c z d))) >     (node node))) Not exactly what you were looking for, but maybe use quasisyntax / unsyntax #` #, something like (untested): ;; define, not define-syntax! (define R (syntax-rules () ((_ r v l) #(red r v l)))) (define B (syntax-rules () ((_ r v l) #(black r v l)))) (define-syntax red-black-set-balance-m (lambda (s) #`(match-lambda ((or #,(B (R (R a x b) y c) z d) #,(B (R a x (R b y c)) z d) ...)) (node node)))) (define red-black-set-balance red-black-set-balance-m) Greetings, Maxime