From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: calcium Newsgroups: gmane.lisp.guile.bugs Subject: bug#33036: Bug with the procedure nil? inside a specific code Date: Sat, 13 Oct 2018 18:17:06 +0200 Message-ID: <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 1539454692 15055 195.159.176.226 (13 Oct 2018 18:18:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 13 Oct 2018 18:18:12 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 To: 33036@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sat Oct 13 20:18:08 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 1gBOUJ-0003ku-Ee for guile-bugs@m.gmane.org; Sat, 13 Oct 2018 20:18:08 +0200 Original-Received: from localhost ([::1]:45883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBOWQ-0004jQ-19 for guile-bugs@m.gmane.org; Sat, 13 Oct 2018 14:20:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBOWK-0004ii-0P for bug-guile@gnu.org; Sat, 13 Oct 2018 14:20:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBOWE-0002PQ-1f for bug-guile@gnu.org; Sat, 13 Oct 2018 14:20:11 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44352) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gBOWA-0002Ki-QJ for bug-guile@gnu.org; Sat, 13 Oct 2018 14:20:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gBOWA-0008Oj-DU for bug-guile@gnu.org; Sat, 13 Oct 2018 14:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: calcium Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 13 Oct 2018 18:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 33036 X-GNU-PR-Package: guile X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.153945479832263 (code B ref -1); Sat, 13 Oct 2018 18:20:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Oct 2018 18:19:58 +0000 Original-Received: from localhost ([127.0.0.1]:48610 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBOW5-0008OH-LU for submit@debbugs.gnu.org; Sat, 13 Oct 2018 14:19:58 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:56402) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBMb8-0005d8-E7 for submit@debbugs.gnu.org; Sat, 13 Oct 2018 12:17:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBMb1-00079b-Vv for submit@debbugs.gnu.org; Sat, 13 Oct 2018 12:16:57 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:58575) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gBMb1-00079W-RP for submit@debbugs.gnu.org; Sat, 13 Oct 2018 12:16:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBMb0-00064r-Lv for bug-guile@gnu.org; Sat, 13 Oct 2018 12:16:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBMaw-0006wC-5V for bug-guile@gnu.org; Sat, 13 Oct 2018 12:16:54 -0400 Original-Received: from knopi.disroot.org ([178.21.23.139]:50106) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gBMav-0006r8-Pt for bug-guile@gnu.org; Sat, 13 Oct 2018 12:16:50 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 2E44335006 for ; Sat, 13 Oct 2018 18:16:47 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at disroot.org Original-Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E9t2AdN9N5p1 for ; Sat, 13 Oct 2018 18:16:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1539447406; bh=e41VddgIkv0QKCGvdLT/rVnZcycuy4ua3KfHKN/peNs=; h=From:Subject:To:Date; b=QxIQ3qmhlnmNmh83Bc/Q6HvUx058SzEu5CL2NFVuO7zCzAk9/fjIF+5Ua5QzzYvhu H9XsvIKKTUKReLbWXlF/y9tSYxp1becx7AihMbEXe87ICw8+k4Op3RnnEpTrWXqzzA wEQSVVlHYwmc/3yXra0hUuqfpIG85nW6KGUFjPBGUD/Pb60y+AMF0XbUvJwWSmCMt+ YhgegFJw49idcF2HByf0qZ0QhUmCL4B28tI/FCZ48VTB1hE+zw9xDd1tFmWw3cRuc2 liZwpVmvrVju/AQu/K77JGmqY+30/Z8E4OszMQQxqQImYka2dt46klO4iRO2mljhZR k/OWRRguEkp9A== Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Sat, 13 Oct 2018 14:19:56 -0400 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:9181 Archived-At: Order of content: 1] --- Setup information 2] --- what is the procedure nil? 3] --- snippet of code that trigger the bug 4] --- snippet of code that doesn't trigger the bug 5] --- Summary and end 1] --- Setup : $ ./config.guess x86_64-pc-linux-gnu $ guile --version guile: warning: failed to install locale guile (GNU Guile) 2.2.3 etc ... -> Guile was installed in a foreign Gnu/Linux distribution via Guix. 2] --- 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 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'." (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. (null? #nil) =3D> #t (null? =E2=80=98()) =3D> #t (nil? #nil) =3D> #t (nil? '()) =3D> #t 3] --- 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 ()) ;;; -END- code with the bug -END- ;;; 4] --- And here follows 3 version that doesn=E2=80=99t trigger this bug. ;;; in this one we remove the call to the loop in the else clause ;;; -START- code that works (1) -START- ;;; (define (not-strange-1 lst) (let loop ((lst lst) (is-empty '())) (cond ((nil? lst) (if (nil? is-empty) 'works (list 'should-not-occur is-empty))) (else 'no-more-bug)))) (not-strange-1 '()) =3D> works (not-strange-1 #nil) =3D> works ;;; -END- code that works (1) -END- ;;; ;;; we change the =E2=80=98() of is-empty to #nil ;;; -START- code that works (2) -START- ;;; (define (not-strange-2 lst) (let loop ((lst lst) (is-empty #nil)) (cond ((nil? lst) (if (nil? is-empty) 'works (list 'should-not-occur is-empty))) (else (loop (cdr lst) is-empty))))) (not-strange-2 '()) =3D> works (not-strange-2 #nil) =3D> works ;;; -END- code that works (2) -END- ;;; ;;; if we use null? instead of nil? at the critical point (nil? is-empty= ) ;;; -START- code that works (3) -START- ;;; (define (not-strange-3 lst) (let loop ((lst lst) (is-empty '())) (cond ((nil? lst) (if (null? is-empty) 'works (list 'should-not-occur is-empty))) (else (loop (cdr lst) is-empty))))) (not-strange-3 '()) =3D> works (not-strange-3 #nil) =3D> works ;;; -END- code that works (3) -END- ;;; 5] --- So in summary : 1) removing the call to the loop in the else clause remove the bug. This is interesting because we don=E2=80=99t enter the else clause 2) using the #nil instead of =E2=80=98() did change the outcome. But except for this case, it doesn't seem to change the outcome to use #nil or =E2=80=98() 3) using null? Instead of nil? did change the outcome. This is similar to point 2. except that we change the procedure instead of the value. I think that there is 2 way to look at this bug: The first one is to consider that it is a bug because nil? and null? should give the same answer. The second one is to consider that nil? should only answer #t when we use it with #nil, and otherwise give #f (this include =E2=80=98() ). --- If you require any further information or did not understand what I said, feel free to contact me at calcium@disroot.org