From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Newsgroups: gmane.lisp.guile.user Subject: Re: syntax taste: use of unquote in macros Date: Tue, 31 Mar 2020 18:56:17 +0200 Message-ID: <87imiktqdq.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="19165"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) To: guile-user@gnu.org Cancel-Lock: sha1:Iww9j5uc6YIg4XnzYcltKAu6oV0= Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Tue Mar 31 18:56:41 2020 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 1jJKBs-0004tT-9j for guile-user@m.gmane-mx.org; Tue, 31 Mar 2020 18:56:40 +0200 Original-Received: from localhost ([::1]:41776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJKBr-0005Cr-8Y for guile-user@m.gmane-mx.org; Tue, 31 Mar 2020 12:56:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45784) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJKBe-00059p-QM for guile-user@gnu.org; Tue, 31 Mar 2020 12:56:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJKBd-0004aL-N5 for guile-user@gnu.org; Tue, 31 Mar 2020 12:56:26 -0400 Original-Received: from ciao.gmane.io ([159.69.161.202]:59814) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jJKBd-0004Zp-H6 for guile-user@gnu.org; Tue, 31 Mar 2020 12:56:25 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1jJKBa-0004Xv-MO for guile-user@gnu.org; Tue, 31 Mar 2020 18:56:22 +0200 X-Injected-Via-Gmane: http://gmane.org/ X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 12 Germinal an 228 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 159.69.161.202 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:16360 Archived-At: Hi Matt, Matt Wette skribis: > I'm not sure if you know about this, but there is a discrepancy in the > way some folks define macros to use unquote (aka ,).   For example, > >> (use-modules (system base pmatch)) >> (pmatch '(foo "bar")  ((foo ,val)  (write val) (newline))) > => "bar" > >> (use-modules (ice-9 match)) >> (match '(foo "bar")  (`(foo ,val)  (write val) (newline))) > => "bar" > > Note the difference in the use of quasiquote (aka `) in the pattern > for (foo ,val): match syntax uses it, pmatch does not. > In Scheme, quasiquote and unquote always come together. > > Is pmatch syntax in bad taste?  I'm looking for opinions. It really depends on what you’re going to use the pattern matcher for. For ‘sxml-match’, it’s more convenient to have literals be the default because there are usually more literals than variables, as in: (sxml-match x ((album (@ (title ,t)) (catalog (num ,n) (fmt ,f)) ...) `(ul (li ,t) (li (b ,n) (i ,f)) ...))) In more general cases, I prefer the (ice-9 match) style because patterns typically have more variables than literals. In one case, I found myself implementing pmatch-style quoting on top of (ice-9 match) so I would have the best of both worlds: https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/installer/tests.scm#n84 :-) Ludo’.