X-Loop: help-debbugs@HIDDEN Subject: bug#48425: Should #nil be equal? to '()? Resent-From: Taylan Kammer <taylan.kammer@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-guile@HIDDEN Resent-Date: Fri, 14 May 2021 19:37:02 +0000 Resent-Message-ID: <handler.48425.B.16210210074855 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 48425 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 48425 <at> debbugs.gnu.org X-Debbugs-Original-To: bug-guile@HIDDEN Received: via spool by submit <at> debbugs.gnu.org id=B.16210210074855 (code B ref -1); Fri, 14 May 2021 19:37:02 +0000 Received: (at submit) by debbugs.gnu.org; 14 May 2021 19:36:47 +0000 Received: from localhost ([127.0.0.1]:47087 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1lhdc6-0001GE-O7 for submit <at> debbugs.gnu.org; Fri, 14 May 2021 15:36:47 -0400 Received: from lists.gnu.org ([209.51.188.17]:58232) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <taylan.kammer@HIDDEN>) id 1lhdc5-0001G7-OY for submit <at> debbugs.gnu.org; Fri, 14 May 2021 15:36:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <taylan.kammer@HIDDEN>) id 1lhdc5-0000SZ-FR for bug-guile@HIDDEN; Fri, 14 May 2021 15:36:45 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]:34493) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <taylan.kammer@HIDDEN>) id 1lhdc3-0001PA-AC for bug-guile@HIDDEN; Fri, 14 May 2021 15:36:45 -0400 Received: by mail-ed1-x52c.google.com with SMTP id l7so35946332edb.1 for <bug-guile@HIDDEN>; Fri, 14 May 2021 12:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=22PZmimoNE3vjqF1MnVx57/cYnrHpb6qHq4m6q3WOnM=; b=CQzo5EjAEm6SCO5irKIZDcrRNC/s+c1WBa7Q/uUCuzUDJ/GbWG+Og0xurfize94veY QKUsd98fPJeSZ7OXDRN9lysKxCWrwFvxtKXb9lZMLa0dC8SSw/28rIqDXGoywu7f3xP9 xz4Tc+nJ7gbJBpBFqj7mtB7mS2PtjRUjvEeiaqG0CAduiQpERL4G5fgIg8TYZ9GBYKfG 9buHabe0N7uKrd/vRN2UJc4QiNWseDbweWLy5aXdgk+bDtdSjIT0I9VdVMTyQKu6NW15 2bpLkRVgmD9TeHsS8GnYKWrxxkeoIUXPQjRyQ1WfMpV2cqpaQMET8I5Qt+wEOZ2Aw8Ar axZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=22PZmimoNE3vjqF1MnVx57/cYnrHpb6qHq4m6q3WOnM=; b=lsLNlgcwkdumYQtQS54lT1qk0bqZeeZcVKJd2zymPKlANqvcaYhO5vyT7HS8tMhXZK 7BFBZQ1NTyT91Rpy09RCiL5FCRwouEB/lECWeBaN2IK5GN51OwV74/ZiamjrrHZXICxV yeB23KTRNkTQVP+AS+e0LEvfNN2ObzHoEpXMeubAWa9394DU4aA/loibdyVMN37Rys1s KWFPh8lQJ4nKJPUCQ63IQI8jLkHKC2lQoCxos5yZBxIfIdfhPYrco80h+ho0qt1FeFlR C76LvAME3XWvQtMUMFXcNsUG2uA9aLJWGR6vqUG0q7ghIY7YQQxdXehjyz7Q73yNMLvo t/pQ== X-Gm-Message-State: AOAM531/w8vcTKPUwUbnlkCIeRyJk5GfKJU1J4u/NaRXjhk5gUNfMCL4 JzH7swptsxmoAiAmn1ADtMecdfhF0Rjzpw== X-Google-Smtp-Source: ABdhPJwXtdVLh8P+PPNHhNybanblPJhimv7EhIGZC/GzYSVFPt1L5ntB2OfzOLRrN2cBe88s8Nj1WA== X-Received: by 2002:a50:cd57:: with SMTP id d23mr56811534edj.5.1621021000807; Fri, 14 May 2021 12:36:40 -0700 (PDT) Received: from [192.168.178.20] (b2b-109-90-125-150.unitymedia.biz. [109.90.125.150]) by smtp.gmail.com with ESMTPSA id qu23sm4076316ejb.1.2021.05.14.12.36.40 for <bug-guile@HIDDEN> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 May 2021 12:36:40 -0700 (PDT) From: Taylan Kammer <taylan.kammer@HIDDEN> Message-ID: <aa23e415-6395-e0a8-6a51-77b249a0a8d0@HIDDEN> Date: Fri, 14 May 2021 21:36:39 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------D4E6815BA424596B2131A0D9" Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=taylan.kammer@HIDDEN; helo=mail-ed1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------D4E6815BA424596B2131A0D9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit I believe it would be better if #nil were equal? to (). It would keep *not* being equal? to #f and as such not disturb the property of transitiveness. Making #nil and () be equal? would be a lot more intuitive since they both represent the empty list, and since equal? is commonly used to test the equality of lists. Meeting this expectation would probably prevent a common type of unexpected behavior where a list coming from Elisp code is not equal? to a list coming from Scheme code, even though they have the same contents. Attached is a patch to realize the change. Note that it increases the size of compiled code that uses equal?. I don't know if this represents a problem or not. Before patch: scheme@(guile-user)> ,disassemble (lambda (x y) (equal? x y)) Disassembly of #<procedure 55dd585a0c58 at <unknown port>:1:13 (x y)> at #x55dd585a0ad4: 0 (instrument-entry 131) at (unknown file):1:13 2 (assert-nargs-ee/locals 3 0) ;; 3 slots (2 args) 3 (eq? 1 0) at (unknown file):1:27 4 (je 29) ;; -> L4 5 (immediate-tag=? 1 7 0) ;; heap-object? 7 (jne 22) ;; -> L3 8 (immediate-tag=? 0 7 0) ;; heap-object? 10 (jne 15) ;; -> L2 11 (static-ref 2 96) ;; #f 13 (immediate-tag=? 2 7 0) ;; heap-object? 15 (je 7) ;; -> L1 16 (call-scm<-scmn-scmn 2 103 107 113) 20 (static-set! 2 87) ;; #f L1: 22 (scm-ref/immediate 2 2 1) 23 (handle-interrupts) 24 (tail-call) L2: 25 (make-immediate 2 4) ;; #f 26 (reset-frame 1) ;; 1 slot 27 (handle-interrupts) 28 (return-values) L3: 29 (make-immediate 2 4) ;; #f 30 (reset-frame 1) ;; 1 slot 31 (handle-interrupts) 32 (return-values) L4: 33 (make-immediate 2 1028) ;; #t 34 (reset-frame 1) ;; 1 slot 35 (handle-interrupts) 36 (return-values) After patch: scheme@(guile-user)> ,disassemble (lambda (x y) (equal? x y)) Disassembly of #<procedure 55b741d3ad50 at <unknown port>:8:13 (x y)> at #x55b741d3ab94: 0 (instrument-entry 145) at (unknown file):8:13 2 (assert-nargs-ee/locals 3 0) ;; 3 slots (2 args) 3 (eq? 1 0) at (unknown file):8:27 4 (je 43) ;; -> L6 5 (immediate-tag=? 1 3583 260) ;; null? 7 (jne 12) ;; -> L2 8 (immediate-tag=? 0 3583 260) ;; null? 10 (je 5) ;; -> L1 11 (make-immediate 2 4) ;; #f 12 (reset-frame 1) ;; 1 slot 13 (handle-interrupts) 14 (return-values) L1: 15 (make-immediate 2 1028) ;; #t 16 (reset-frame 1) ;; 1 slot 17 (handle-interrupts) 18 (return-values) L2: 19 (immediate-tag=? 1 7 0) ;; heap-object? 21 (jne 22) ;; -> L5 22 (immediate-tag=? 0 7 0) ;; heap-object? 24 (jne 15) ;; -> L4 25 (static-ref 2 96) ;; #f 27 (immediate-tag=? 2 7 0) ;; heap-object? 29 (je 7) ;; -> L3 30 (call-scm<-scmn-scmn 2 103 107 113) 34 (static-set! 2 87) ;; #f L3: 36 (scm-ref/immediate 2 2 1) 37 (handle-interrupts) 38 (tail-call) L4: 39 (make-immediate 2 4) ;; #f 40 (reset-frame 1) ;; 1 slot 41 (handle-interrupts) 42 (return-values) L5: 43 (make-immediate 2 4) ;; #f 44 (reset-frame 1) ;; 1 slot 45 (handle-interrupts) 46 (return-values) L6: 47 (make-immediate 2 1028) ;; #t 48 (reset-frame 1) ;; 1 slot 49 (handle-interrupts) 50 (return-values) - Taylan --------------D4E6815BA424596B2131A0D9 Content-Type: text/plain; charset=UTF-8; name="0001-Make-nil-and-equal-as-per-equal.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="0001-Make-nil-and-equal-as-per-equal.patch" RnJvbSA0YWQyMGU3NjBjNDc0NWVhMjdiYzgzYTIxZDEyYThlZjg0Yzg3NDQ1IE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBUYXlsYW4gS2FtbWVyIDx0YXlsYW4ua2FtbWVyQGdt YWlsLmNvbT4KRGF0ZTogRnJpLCAxNCBNYXkgMjAyMSAxODozNToxMiArMDIwMApTdWJqZWN0 OiBbUEFUQ0hdIE1ha2UgI25pbCBhbmQgKCkgZXF1YWwgYXMgcGVyIGVxdWFsPy4KCiogbGli Z3VpbGUvZXEuYyAoc2NtX2VxdWFsX3ApOiBBZGQgY2hlY2sgdG8gc2VlIGlmIGJvdGggYXJn dW1lbnRzCnNhdGlzZnkgbnVsbD8gYW5kIHJldHVybiB0cnVlIGlmIHRoZXkgZG8uCiogbW9k dWxlL2xhbmd1YWdlL3RyZWUtaWwvY29tcGlsZS1jcHMuc2NtIChjYW5vbmljYWxpemUpOiBJ biBlcXVhbD8KcHJpbWNhbGxzLCBhZGQgYSBjaGVjayB0byBzZWUgaWYgYm90aCBhcmd1bWVu dHMgc2F0aXNmeSBudWxsPy4KKiBtb2R1bGUvbGFuZ3VhZ2UvdHJlZS1pbC9wZXZhbC5zY20g KHBldmFsKTogSW4gdGhlIHBhcnRpYWwgZXZhbHVhdGlvbgpvZiBlcXVhbGl0eSBwcmltaXRp dmVzLCBkb24ndCBmb2xkIHRvIGVxPyBmb3IgI25pbCBhbmQgJygpLgotLS0KIGxpYmd1aWxl L2VxLmMgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAzICsrCiBtb2R1bGUvbGFuZ3Vh Z2UvdHJlZS1pbC9jb21waWxlLWNwcy5zY20gfCAzOSArKysrKysrKysrKysrKysrLS0tLS0t LS0tCiBtb2R1bGUvbGFuZ3VhZ2UvdHJlZS1pbC9wZXZhbC5zY20gICAgICAgfCAgNCArLS0K IDMgZmlsZXMgY2hhbmdlZCwgMzAgaW5zZXJ0aW9ucygrKSwgMTYgZGVsZXRpb25zKC0pCgpk aWZmIC0tZ2l0IGEvbGliZ3VpbGUvZXEuYyBiL2xpYmd1aWxlL2VxLmMKaW5kZXggNjI3ZDZm MDliLi4wYThhNjA2MzQgMTAwNjQ0Ci0tLSBhL2xpYmd1aWxlL2VxLmMKKysrIGIvbGliZ3Vp bGUvZXEuYwpAQCAtMjk5LDYgKzI5OSw5IEBAIHNjbV9lcXVhbF9wIChTQ00geCwgU0NNIHkp CiAgIFNDTV9USUNLOwogICBpZiAoc2NtX2lzX2VxICh4LCB5KSkKICAgICByZXR1cm4gU0NN X0JPT0xfVDsKKyAgLyogTWFrZSBzdXJlICNuaWwgYW5kICgpIGFyZSBlcXVhbC4gKi8KKyAg aWYgKHNjbV9pc19udWxsICh4KSAmJiBzY21faXNfbnVsbCAoeSkpCisgICAgcmV0dXJuIFND TV9CT09MX1Q7CiAgIGlmIChTQ01fSU1QICh4KSkKICAgICByZXR1cm4gU0NNX0JPT0xfRjsK ICAgaWYgKFNDTV9JTVAgKHkpKQpkaWZmIC0tZ2l0IGEvbW9kdWxlL2xhbmd1YWdlL3RyZWUt aWwvY29tcGlsZS1jcHMuc2NtIGIvbW9kdWxlL2xhbmd1YWdlL3RyZWUtaWwvY29tcGlsZS1j cHMuc2NtCmluZGV4IGZmYzgzMDhhNi4uYTBhM2UyMzgxIDEwMDY0NAotLS0gYS9tb2R1bGUv bGFuZ3VhZ2UvdHJlZS1pbC9jb21waWxlLWNwcy5zY20KKysrIGIvbW9kdWxlL2xhbmd1YWdl L3RyZWUtaWwvY29tcGlsZS1jcHMuc2NtCkBAIC0yNDc4LDE0ICsyNDc4LDE1IEBAIGludGVn ZXIuIgogICAgICAgICAobGV0ICgpCiAgICAgICAgICAgKGRlZmluZS1zeW50YXgtcnVsZSAo cHJpbWNhbGwgbmFtZSAuIGFyZ3MpCiAgICAgICAgICAgICAobWFrZS1wcmltY2FsbCBzcmMg J25hbWUgKGxpc3QgLiBhcmdzKSkpCi0gICAgICAgICAgKGRlZmluZS1zeW50YXggcHJpbWNh bGwtY2hhaW4KKyAgICAgICAgICAoZGVmaW5lLXN5bnRheCBwcmltY2FsbC1jb25kLWNoYWlu CiAgICAgICAgICAgICAoc3ludGF4LXJ1bGVzICgpCi0gICAgICAgICAgICAgICgoXyB4KSB4 KQotICAgICAgICAgICAgICAoKF8geCAuIHkpCi0gICAgICAgICAgICAgICAobWFrZS1jb25k aXRpb25hbCBzcmMgKHByaW1jYWxsIC4geCkgKHByaW1jYWxsLWNoYWluIC4geSkKLSAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIChtYWtlLWNvbnN0IHNyYyAjZikpKSkpCi0g ICAgICAgICAgKGRlZmluZS1zeW50YXgtcnVsZSAoYm9vbCB4KQotICAgICAgICAgICAgKG1h a2UtY29uZGl0aW9uYWwgc3JjIHggKG1ha2UtY29uc3Qgc3JjICN0KSAobWFrZS1jb25zdCBz cmMgI2YpKSkKKyAgICAgICAgICAgICAgKChfIGNvbnNlcXVlbnQgYWx0ZXJuYXRlKSBjb25z ZXF1ZW50KQorICAgICAgICAgICAgICAoKF8gdGVzdCB0ZXN0KiAuLi4gY29uc2VxdWVudCBh bHRlcm5hdGUpCisgICAgICAgICAgICAgICAobWFrZS1jb25kaXRpb25hbAorICAgICAgICAg ICAgICAgIHNyYworICAgICAgICAgICAgICAgIChwcmltY2FsbCAuIHRlc3QpCisgICAgICAg ICAgICAgICAgKHByaW1jYWxsLWNvbmQtY2hhaW4gdGVzdCogLi4uIGNvbnNlcXVlbnQgYWx0 ZXJuYXRlKQorICAgICAgICAgICAgICAgIGFsdGVybmF0ZSkpKSkKICAgICAgICAgICAod2l0 aC1sZXhpY2FscyBzcmMgKGEgYikKICAgICAgICAgICAgIChtYWtlLWNvbmRpdGlvbmFsCiAg ICAgICAgICAgICAgc3JjCkBAIC0yNDk0LDE0ICsyNDk1LDI0IEBAIGludGVnZXIuIgogICAg ICAgICAgICAgIChtYXRjaCAocHJpbWNhbGwtbmFtZSBleHApCiAgICAgICAgICAgICAgICAo J2Vxdj8KICAgICAgICAgICAgICAgICA7OyBDb21wbGV0ZWx5IGlubGluZS4KLSAgICAgICAg ICAgICAgICAocHJpbWNhbGwtY2hhaW4gKGhlYXAtbnVtYmVyPyBhKQotICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAoaGVhcC1udW1iZXI/IGIpCi0gICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIChib29sIChwcmltY2FsbCBoZWFwLW51bWJlcnMtZXF1YWw/IGEg YikpKSkKKyAgICAgICAgICAgICAgICAocHJpbWNhbGwtY29uZC1jaGFpbgorICAgICAgICAg ICAgICAgICAoaGVhcC1udW1iZXI/IGEpCisgICAgICAgICAgICAgICAgIChoZWFwLW51bWJl cj8gYikKKyAgICAgICAgICAgICAgICAgKGhlYXAtbnVtYmVycy1lcXVhbD8gYSBiKQorICAg ICAgICAgICAgICAgICAobWFrZS1jb25zdCBzcmMgI3QpCisgICAgICAgICAgICAgICAgICht YWtlLWNvbnN0IHNyYyAjZikpKQogICAgICAgICAgICAgICAgKCdlcXVhbD8KLSAgICAgICAg ICAgICAgICA7OyBQYXJ0aWFsbHkgaW5saW5lLgotICAgICAgICAgICAgICAgIChwcmltY2Fs bC1jaGFpbiAoaGVhcC1vYmplY3Q/IGEpCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIChoZWFwLW9iamVjdD8gYikKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg KHByaW1jYWxsIGVxdWFsPyBhIGIpKSkpKSkpKQorICAgICAgICAgICAgICAgIDs7IE1ha2Ug c3VyZSAjbmlsIGFuZCAoKSBhcmUgZXF1YWwuCisgICAgICAgICAgICAgICAgKHByaW1jYWxs LWNvbmQtY2hhaW4KKyAgICAgICAgICAgICAgICAgKG51bGw/IGEpCisgICAgICAgICAgICAg ICAgIChudWxsPyBiKQorICAgICAgICAgICAgICAgICAobWFrZS1jb25zdCBzcmMgI3QpCisg ICAgICAgICAgICAgICAgIDs7IFBhcnRpYWxseSBpbmxpbmUuCisgICAgICAgICAgICAgICAg IChwcmltY2FsbC1jb25kLWNoYWluCisgICAgICAgICAgICAgICAgICAoaGVhcC1vYmplY3Q/ IGEpCisgICAgICAgICAgICAgICAgICAoaGVhcC1vYmplY3Q/IGIpCisgICAgICAgICAgICAg ICAgICAocHJpbWNhbGwgZXF1YWw/IGEgYikKKyAgICAgICAgICAgICAgICAgIChtYWtlLWNv bnN0IHNyYyAjZikpKSkpKSkpKQogCiAgICAgICAgKCgkIDxwcmltY2FsbD4gc3JjICd2ZWN0 b3IgYXJncykKICAgICAgICAgOzsgRXhwYW5kIHRvICJhbGxvY2F0ZS12ZWN0b3IiICsgInZl Y3Rvci1pbml0ISIuCmRpZmYgLS1naXQgYS9tb2R1bGUvbGFuZ3VhZ2UvdHJlZS1pbC9wZXZh bC5zY20gYi9tb2R1bGUvbGFuZ3VhZ2UvdHJlZS1pbC9wZXZhbC5zY20KaW5kZXggZDkxMDA4 OGM5Li45Mzc0MWI0Y2YgMTAwNjQ0Ci0tLSBhL21vZHVsZS9sYW5ndWFnZS90cmVlLWlsL3Bl dmFsLnNjbQorKysgYi9tb2R1bGUvbGFuZ3VhZ2UvdHJlZS1pbC9wZXZhbC5zY20KQEAgLTE0 MzAsOCArMTQzMCw4IEBAIHRvcC1sZXZlbCBiaW5kaW5ncyBmcm9tIEVOViBhbmQgcmV0dXJu IHRoZSByZXN1bHRpbmcgZXhwcmVzc2lvbi4iCiAgICAgICAgICAgICgoZXE/IG5hbWUgJ2Vx PykKICAgICAgICAgICAgIDs7IEFscmVhZHkgaW4gYSByZWR1Y2VkIHN0YXRlLgogICAgICAg ICAgICAgKG1ha2UtcHJpbWNhbGwgc3JjICdlcT8gKGxpc3QgYSBiKSkpCi0gICAgICAgICAg ICgob3IgKG1lbXEgdiAnKCNmICN0ICgpICNuaWwpKSAoc3ltYm9sPyB2KSAoY2hhcj8gdikK LSAgICAgICAgICAgICAgICA7OyBPbmx5IGZvbGQgdG8gZXE/IHZhbHVlIGlzIGEgZml4bnVt IG9uIHRhcmdldCBhbmQKKyAgICAgICAgICAgKChvciAobWVtcSB2ICcoI2YgI3QpKSAoc3lt Ym9sPyB2KSAoY2hhcj8gdikKKyAgICAgICAgICAgICAgICA7OyBPbmx5IGZvbGQgdG8gZXE/ IGlmIHZhbHVlIGlzIGEgZml4bnVtIG9uIHRhcmdldCBhbmQKICAgICAgICAgICAgICAgICA7 OyBob3N0LCBhcyBjb25zdGFudCBmb2xkaW5nIG1heSBoYXZlIHVzIGNvbXBhcmUgb24gaG9z dAogICAgICAgICAgICAgICAgIDs7IGFzIHdlbGwuCiAgICAgICAgICAgICAgICAgKGFuZCAo ZXhhY3QtaW50ZWdlcj8gdikKLS0gCjIuMzAuMgoK --------------D4E6815BA424596B2131A0D9--
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Taylan Kammer <taylan.kammer@HIDDEN> Subject: bug#48425: Acknowledgement (Should #nil be equal? to '()?) Message-ID: <handler.48425.B.16210210074855.ack <at> debbugs.gnu.org> References: <aa23e415-6395-e0a8-6a51-77b249a0a8d0@HIDDEN> X-Gnu-PR-Message: ack 48425 X-Gnu-PR-Package: guile Reply-To: 48425 <at> debbugs.gnu.org Date: Fri, 14 May 2021 19:37:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-guile@HIDDEN If you wish to submit further information on this problem, please send it to 48425 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 48425: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D48425 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
Received: (at control) by debbugs.gnu.org; 15 May 2021 17:34:08 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat May 15 13:34:07 2021 Received: from localhost ([127.0.0.1]:49178 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1lhyAx-0006dV-Oq for submit <at> debbugs.gnu.org; Sat, 15 May 2021 13:34:07 -0400 Received: from mail-ej1-f47.google.com ([209.85.218.47]:34733) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <taylan.kammer@HIDDEN>) id 1lhyAw-0006cv-Jo for control <at> debbugs.gnu.org; Sat, 15 May 2021 13:34:06 -0400 Received: by mail-ej1-f47.google.com with SMTP id p24so1827246ejb.1 for <control <at> debbugs.gnu.org>; Sat, 15 May 2021 10:34:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=EOzO6cz0voXsaQP9AlQqKxmyQ8UGqljyrzm3AsQ/p5M=; b=OYE2vcQ7X7Zn7xgw4EW45jL9BtZksjd34qaUYpd4PS5JB4UnYsLpg8xRvCexbMPZZf TZ5hYfjkkt3qXi5ejSV2TEJ9iMAUvH0xVaJFuhcJr6UZeCRe1w7y338sUYZkQMmnRB1E g44NA4pzYKTMw98pIgBxgVD2z0c71dsGNCqUADb8uNWTLWcnfNXtN0SrqZ6bbH+IITds M0fnmSpCVIx6C4BVpv9/ELfCOdIh48ugmLXAEvuas+LM7VBSQDmk5ymB5nN5mO0XFREF 4Bu6uVScB9XOaPpjjA1y2IRmGfl37liRbVmRepRCaHvnL9h49FqBuXTyoSUq+HEx1e3H jzKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=EOzO6cz0voXsaQP9AlQqKxmyQ8UGqljyrzm3AsQ/p5M=; b=oJV+4PWcG2cajsZOrBcns/uQD7gkosZ6zA5bxWY/jonQS7Z5W4s/J8MJtHM9hM6hDP 473FtB73jPrWC70dop4Y5FEMpZjH94WZuZOSNEz3mvjLY5cUpXdxYOHY52tcbuQbAmF6 ORdpLVJ2VkOFTY1zIM7s7RRnQ8lEnpjlGOJUtn3j81O8Vf+hC2ylo020NPFaje0BYZYG y+PFJimLwRhL0XbQjpDix30rclEjCdzLWGAWRn12wLipLI5fW77XXVHPnK34ZihYi69s YpAwjnnOfVmayX+phu2XsVkblsCP94qAHw0V9RPZPSwm8R8tBze5wxhba/mvlBcCCJau X16Q== X-Gm-Message-State: AOAM533mP9HOMR9hnidJMrKT390H0Gmjk6kfBuA/o3D4jeA7buAiV8j+ A+c7ZR6yjCejlT1KQR1UjIwnponT77E= X-Google-Smtp-Source: ABdhPJzZdQ4m5p1FS3P05ClR8snkqe7j9cm6/zqQHs6A0TFOEpdJJSlWvroGi9ksmHtcMr6kaz7siA== X-Received: by 2002:a17:906:79c8:: with SMTP id m8mr54243957ejo.260.1621100040815; Sat, 15 May 2021 10:34:00 -0700 (PDT) Received: from [192.168.178.20] (b2b-109-90-125-150.unitymedia.biz. [109.90.125.150]) by smtp.gmail.com with ESMTPSA id z11sm5614183ejc.122.2021.05.15.10.34.00 for <control <at> debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 15 May 2021 10:34:00 -0700 (PDT) To: control <at> debbugs.gnu.org From: Taylan Kammer <taylan.kammer@HIDDEN> Subject: tags 48425 + patch Message-ID: <eef1b6d6-56ec-9a84-ef76-c246b681afad@HIDDEN> Date: Sat, 15 May 2021 19:33:59 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) tags 48425 + patch
X-Loop: help-debbugs@HIDDEN Subject: bug#48425: Should #nil be equal? to '()? Resent-From: Leo Prikler <leo.prikler@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-guile@HIDDEN Resent-Date: Thu, 24 Jun 2021 18:32:02 +0000 Resent-Message-ID: <handler.48425.B48425.162455947930224 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 48425 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: Taylan Kammer <taylan.kammer@HIDDEN>, 48425 <at> debbugs.gnu.org Received: via spool by 48425-submit <at> debbugs.gnu.org id=B48425.162455947930224 (code B ref 48425); Thu, 24 Jun 2021 18:32:02 +0000 Received: (at 48425) by debbugs.gnu.org; 24 Jun 2021 18:31:19 +0000 Received: from localhost ([127.0.0.1]:44119 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1lwU8F-0007qu-7S for submit <at> debbugs.gnu.org; Thu, 24 Jun 2021 14:31:19 -0400 Received: from mailrelay.tugraz.at ([129.27.2.202]:21805) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <leo.prikler@HIDDEN>) id 1lwU8C-0007nH-NQ for 48425 <at> debbugs.gnu.org; Thu, 24 Jun 2021 14:31:18 -0400 Received: from nijino.local (62-116-34-49.adsl.highway.telekom.at [62.116.34.49]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4G9pcK0QK0z3wmc; Thu, 24 Jun 2021 20:31:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1624559473; bh=q+aLm3K8Lbiar8lKZtEUVMVaErIBBFpDcWxUhA1v45E=; h=Subject:From:To:Date:In-Reply-To:References; b=esf1p/1+am8tt0SNXjaGjKbK7x/K2Q8CHHt3q3jb9iSuU+0+709iT+UuDl8QRgiT6 /nNv5W0nEsb+K395aJo5qVhDTOTAuDQTSqThRtP5v+CLptKdVBpRGlev6Ot4nAutLp gnVtunsXCJaO0ZcbaPfMCjLPHTb0nnpshs4aiiFU= Message-ID: <75c724023a126850b3b21a296fb658330038e670.camel@HIDDEN> From: Leo Prikler <leo.prikler@HIDDEN> Date: Thu, 24 Jun 2021 20:31:12 +0200 In-Reply-To: <aa23e415-6395-e0a8-6a51-77b249a0a8d0@HIDDEN> References: <aa23e415-6395-e0a8-6a51-77b249a0a8d0@HIDDEN> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUG-Backscatter-control: bt4lQm5Tva3SBgCuw0EnZw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.116 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Hi Taylan, after a lengthy discussion in IRC, you invited me to reply to this bug report, so that's what I'm doing. I will make short references to that discussion, but I won't rehash all of it. Anyone who is interested in reading it in all detail, should inspect the public logs: http://logs.guix.gnu.org/guile/2021-06-24.log#170309 Am Freitag, den 14.05.2021, 21:36 +0200 schrieb Taylan Kammer: > I believe it would be better if #nil were equal? to (). > > It would keep *not* being equal? to #f and as such not disturb the > property of transitiveness. I don't think there's a good reason to prefer one of this equal?ity over the other – it all comes down to personal preference if at all. > Making #nil and () be equal? would be a lot more intuitive since > they both represent the empty list, and since equal? is commonly > used to test the equality of lists. Meeting this expectation would > probably prevent a common type of unexpected behavior where a list > coming from Elisp code is not equal? to a list coming from Scheme > code, even though they have the same contents. I don't think, that this is a good reason to make them equal? We've had our lengthy discussion on the philosophy of equality, which I'm going to cut short here, as that's not the point you're making, but for the protocol's sake, #nil and '() are not philosophically equal? Regarding intuitiveness, I think this actually does more harm than good. I could argue that #nil be equal? to #f on the grounds of intuitiveness, but more importantly (if (equal? a b) (equal? (if a #t #f) (if b #t #f))) should only ever return #t or *unspecified*, never #f (insert '() and #nil as a and b). Finally on the point of making equal?ity work that way for the sake of interoperability with other Lisp dialects such as Emacs Lisp or Clojure, this assumes that this style of comparison through equal? is "good Scheme", when I'd argue, that it is in fact not. Pattern matching and dedicated comparison operators are much saner alternatives most of the time. There are multiple ways of getting around the issue of #nil, '() and #f not being equal? to each other. The first would be to define an equal- modulo-nil? procedure, which returns #t if both arguments are nil? Another, that would implement your style, would be the following: --8<---------------cut here---------------start------------->8--- ;; Don't forget to test this when actually using it (define my-equal? (match-lambda* ((() ()) #t) ;; match '() against #nil (((a . as) (b . bs)) (and (my-equal? a b) ;; recurse into the first sub-element (list= my-equal? as bs))) ;; recurse into the others ((a b) (equal? a b)))) ;; fall back to base equal? --8<---------------cut here---------------end--------------->8--- Of course, you can also take the equal? you wrote for this patch and include it in your own library, but be sure to document it so as to not confuse the readers of your code :) Note, that any such implementations will come with certain limitations, but I suppose that's what you'd want out of them. > Attached is a patch to realize the change. Note that it increases > the size of compiled code that uses equal?. I don't know if this > represents a problem or not. I personally don't think bytecode optimizations are something to consider if one can achieve correctness on the other hand, but this solution has the downside of being both wrong (philosophically, as discussed above and in IRC) and heavier to compute. That's not something a standard library should aim for :P Regards, Leo
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.