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.bugs Subject: bug#48318: (ice-9 match) does not allow distinguishing between () and #nil Date: Thu, 13 May 2021 22:39:45 +0200 Message-ID: <26e0536a8f0c16f53002b045cb7e9a30a1e8a09e.camel@telenet.be> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-pggHsW0EOlNpigA66VFn" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39876"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.34.2 To: Taylan Kammer , 48318@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Thu May 13 22:41:07 2021 Return-path: Envelope-to: guile-bugs@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 1lhI8p-000ADb-9F for guile-bugs@m.gmane-mx.org; Thu, 13 May 2021 22:41:07 +0200 Original-Received: from localhost ([::1]:48312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhI8o-0004JF-Bx for guile-bugs@m.gmane-mx.org; Thu, 13 May 2021 16:41:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhI8k-0004J4-N4 for bug-guile@gnu.org; Thu, 13 May 2021 16:41:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:32846) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lhI8k-0004wf-Fd for bug-guile@gnu.org; Thu, 13 May 2021 16:41:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lhI8k-0005bQ-DP for bug-guile@gnu.org; Thu, 13 May 2021 16:41:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 13 May 2021 20:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48318 X-GNU-PR-Package: guile Original-Received: via spool by 48318-submit@debbugs.gnu.org id=B48318.162093840721441 (code B ref 48318); Thu, 13 May 2021 20:41:02 +0000 Original-Received: (at 48318) by debbugs.gnu.org; 13 May 2021 20:40:07 +0000 Original-Received: from localhost ([127.0.0.1]:44389 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lhI7r-0005Zg-6J for submit@debbugs.gnu.org; Thu, 13 May 2021 16:40:07 -0400 Original-Received: from laurent.telenet-ops.be ([195.130.137.89]:55732) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lhI7o-0005ZM-B9 for 48318@debbugs.gnu.org; Thu, 13 May 2021 16:40:06 -0400 Original-Received: from ptr-bvsjgyjmffd7q9timvx.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:aaf1:9810:a0b8:a55d]) by laurent.telenet-ops.be with bizsmtp id 4Lg22500J0mfAB401Lg21T; Thu, 13 May 2021 22:40:02 +0200 In-Reply-To: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1620938402; bh=utKkrWUYbxFejb9bPr5JmaDvNkULXHiqFR6lCDcg4As=; h=Subject:From:To:Date:In-Reply-To:References; b=s3rqA0DL15DphmZ6rAdP0kRrG664ZG/orzlKwkPMqSB+ojziSQQ5eVQsIjIYdT5h2 TfV6nReQQNzYRkbMgXlMAfhBR8NEIsa4XNxTAmJE9IIZUCa29Bln9OJ4Lk4FhMD+pr 7QPKRmlCt7wMTJUlRXxA6S5W88+aKByfy7dBg2Mc9Z7m0GBirgCr+MVpHn52tXWubA fWs2i8h2Mlzdd2Z0bZ5bW5UWvMHwiMOfacuaFJiA9F39M+FyrlsfXS/Gxu4KxwXBCZ eiUro3pKCM2gtxVOsFi+2XwZdOe3GijZ5yKF2mCXy4JKo05OT0oXef2joAq41UGo6G 31QxZpGgWyu3g== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:10053 Archived-At: --=-pggHsW0EOlNpigA66VFn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Taylan Kammer schreef op do 13-05-2021 om 21:14 [+0200]: > Hi Maxime, >=20 > I believe that match conflating () and #nil is the right thing, > even if the current implementation does it unintentionally. >=20 > Those two values should be considered "the same" in most situations > even though (eqv? #nil '()) is false. Conflating #nil and () is reasonable for my use case, though this conflation should be documented. > In fact I think they should be equal? to each other. It feels > wrong that (equal? '(foo . #nil) '(foo . ())) evaluates to false, > even though both arguments represent the list '(foo). The guile manual has some information on this. (6.24.2.1 Nil, under 6.24.2 Emacs Lisp). > Please note that #nil is not ever supposed to be used intentionally. I know, but ... > It's there purely as an Elisp compatibility trick, and the only time > Scheme could should receive it is when receiving data generated by > Elisp code. For instance when Elisp code generates a list, it would > be terminated by #nil. (Which is why I think it should equal? '().) I have been porting some common lisp code to Guile Scheme. I replaced '() with #nil, which allows me to largely ignore whether Lisp nil is used as end-of-list or as boolean for now (I'm in the process of replacing it with '() or #f where appropriate). Being able to directly refer to #nil, to perform equality checks like (eq? #f #nil) --> #f, (eq? '() #nil) --> #f, ... can be useful for writing Scheme code that could be called from both elisp and Scheme when the compatibility isn't transparent. For example, suppose (ice-9 match) actual= ly did not conflate #nil and () (which is what I initially thought; I expected (ice-9 match) to compare atoms with eqv?), then the following code ... ;; Somewhat contrived (untested), but based on some real code (define=20 (match-lambda ((_ . stuff) stuff) (() 0))) ... would need to be rewritten to something like ... ;; Somewhat contrived (untested), but based on some real code (define=20 (match-lambda ((_ . stuff) stuff) (() 0) (#nil 0))) Also, consider the 'case' syntax. Greetings, Maxime. --=-pggHsW0EOlNpigA66VFn Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYJ2OkxccbWF4aW1lZGV2 b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7n9CAP9lTwPh87IbXbJo1IUdfB01PtTF X1ZM4OaJRr4Fol27KwEA3FsAk/qEirTQtCvOvJRG4YbQpu0Y5gDNO0IpybEt1g8= =c75C -----END PGP SIGNATURE----- --=-pggHsW0EOlNpigA66VFn--