From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#33036: Bug with the procedure nil? inside a specific code Date: Sat, 13 Oct 2018 21:11:44 -0400 Message-ID: <87va65uyb3.fsf@netris.org> References: <2cf0a45c-e973-79f5-6ab8-6794a68495d0@disroot.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1539479464 1426 195.159.176.226 (14 Oct 2018 01:11:04 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 14 Oct 2018 01:11:04 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 33036@debbugs.gnu.org To: calcium Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sun Oct 14 03:11:00 2018 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBUvs-0000HA-3w for guile-bugs@m.gmane.org; Sun, 14 Oct 2018 03:11:00 +0200 Original-Received: from localhost ([::1]:46745 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBUxy-0005Fi-BP for guile-bugs@m.gmane.org; Sat, 13 Oct 2018 21:13:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBUxt-0005Fb-7O for bug-guile@gnu.org; Sat, 13 Oct 2018 21:13:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBUxq-0006Fn-1w for bug-guile@gnu.org; Sat, 13 Oct 2018 21:13:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44404) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gBUxp-0006FR-UB for bug-guile@gnu.org; Sat, 13 Oct 2018 21:13:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gBUxp-00014o-Iz for bug-guile@gnu.org; Sat, 13 Oct 2018 21:13:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 14 Oct 2018 01:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33036 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 33036-submit@debbugs.gnu.org id=B33036.15394795284070 (code B ref 33036); Sun, 14 Oct 2018 01:13:01 +0000 Original-Received: (at 33036) by debbugs.gnu.org; 14 Oct 2018 01:12:08 +0000 Original-Received: from localhost ([127.0.0.1]:48662 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBUwy-00013Z-9z for submit@debbugs.gnu.org; Sat, 13 Oct 2018 21:12:08 -0400 Original-Received: from world.peace.net ([64.112.178.59]:35750) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBUww-000138-FX for 33036@debbugs.gnu.org; Sat, 13 Oct 2018 21:12:07 -0400 Original-Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gBUwp-0000JM-MV; Sat, 13 Oct 2018 21:11:59 -0400 In-Reply-To: <2cf0a45c-e973-79f5-6ab8-6794a68495d0@disroot.org> (calcium's message of "Sat, 13 Oct 2018 18:17:06 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:9182 Archived-At: Hi, calcium writes: > The procedure nil? is not listed in the procedure index : > https://www.gnu.org/software/guile/docs/docs-2.0/guile-ref/Procedure-Inde= x.html The link above is the manual for Guile 2.0, which didn't have 'nil?'. It was added in Guile 2.2. > There is a page that speak about nil : > https://www.gnu.org/software/guile/manual/html_node/Nil.html > However it doesn=E2=80=99t mention the nil? Procedure > > The only documentation that I found about nil? is this one : > > (procedure-documentation nil?) > =3D> "- Scheme Procedure: nil? x\n Return `#t' iff X is nil, else > return `#f'." I agree that the documentation for 'nil?' is woefully inadequate. We should add a manual entry for 'nil?' and improve its docstring. 'nil?' tests whether Emacs Lisp code would consider the value to be nil, i.e. whether it would be considered false by Elisp 'if' or 'cond'. Scheme has two distinct values for the empty list () and false #f. In Elisp, both of these concepts are represented by the same value: nil. As a result, the empty list is considered "true" in Scheme, and "false" in Elisp. In other words, 'nil?' returns #t if its argument is #f, (), or #nil, otherwise it returns #f. > (procedure-documentation null?) > =3D> "- Scheme Procedure: null? x\n Return `#t' iff X is the empty > list, else `#f'." > > The procedure documentation is not the same for nil? and null? > They seem nonetheless to be the same. No, they differ in their handling of #f: (null? #f) =3D> #f (nil? #f) =3D> #t > Here is the bug that I found : > > ;;; -START- code with the bug -START- ;;; > > (define (strange lst) > (let loop ((lst lst) > (is-empty '())) > (cond ((nil? lst) > (if (nil? is-empty) 'works > (list 'should-not-occur is-empty))) > (else > (loop (cdr lst) > is-empty))))) > > (strange '()) > =3D> (should-not-occur ()) > > (strange #nil) > =3D> (should-not-occur ()) Indeed, this certainly indicates a bug. I believe the bug is in 'local-type-fold' in (language cps type-fold). It contains a local procedure 'scalar-value' which, if I understand correctly, seems to incorrectly assume that (nil? x) returns #t if and only if X is 'eq?' to #nil. To be continued... Thanks very much for this detailed report! Regards, Mark