From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zelphir Kaltstahl Newsgroups: gmane.lisp.guile.user Subject: Re: Surprising behavior of eq? Date: Sun, 20 Sep 2020 14:19:46 +0200 Message-ID: <8e1d9874-4659-cca5-03da-c2c0df102c56@posteo.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7533"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Icedove/68.10.0 To: Guile User Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Sep 20 14:20:05 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 1kJyK5-0001qr-RQ for guile-user@m.gmane-mx.org; Sun, 20 Sep 2020 14:20:05 +0200 Original-Received: from localhost ([::1]:40920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJyK4-0003wH-T2 for guile-user@m.gmane-mx.org; Sun, 20 Sep 2020 08:20:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJyJr-0003vs-Vn for guile-user@gnu.org; Sun, 20 Sep 2020 08:19:52 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:60809) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJyJp-00042V-U9 for guile-user@gnu.org; Sun, 20 Sep 2020 08:19:51 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 728C82400FB for ; Sun, 20 Sep 2020 14:19:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1600604387; bh=nohjihP+WHC5EcVARrLoB9eZgJyK+a2eEtl0b6U+NBc=; h=Subject:From:To:Date:From; b=djNux8ZLh/ZkKGFRvEvsaQghj1sB9MnhYSh05w/8SLlzMcYnf70h+PXXgHiAEOGdx kembPXuW8zatYt2SakaxULi3siZHWH6diSSGrXv8n5/e16i/Hvy5ug8SV4iJJ1STSa 1FQSVUzOwJWF6ZaiL82RzUL0o2eogqyzbqkJdRVTzkpHezPVJ2ULcICvpDpmKZ2QLe nFo9QV6Fkc8glSsOCjaUIN16ixqvVWQmbTAESG/XqDx8qECnVqxjONx2PiiOFk1rB9 /XmZVWXTxNfYDMz1TtAOSZO+PaFW38SspUmbiL3GPNo+U4mD2yRb1Xo8Kt6jVOyfIy Xp5Lm1lNjxTmg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4BvRTb0lxkz9rxT for ; Sun, 20 Sep 2020 14:19:47 +0200 (CEST) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=185.67.36.66; envelope-from=zelphirkaltstahl@posteo.de; helo=mout02.posteo.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/20 08:16:09 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] 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, HTML_MESSAGE=0.001, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 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:16931 Archived-At: Sorry, I misclicked "send" when I wanted to further edit my e-mail ... My Guile version is: ~~~~ (version) $6 = "3.0.4" ~~~~ On 20.09.20 14:16, Zelphir Kaltstahl wrote: > > Hello Guile users, > > I just noticed something weird about eq?. > > My Guile version is: > > > I get the different results, depending on whether I define some > bindings in a let or using define: > > (In Emacs Geiser:) > > ~~~~ > (define x '(10 9)) > (define y '(10 9)) > (eq? x y) > $2 = #f > > (let ([x '(10 9)] > [y '(10 9)]) > (eq? x y)) > $3 = #t > ~~~~ > > Is this intentional or a bug? > > I first noticed something strange when writing the following code: > > ~~~~DEFINITION~~~~ > (define make-multiple-list-remover > (λ (equal-proc) > (λ (lst unwanted) > (let loop ([remaining-list lst]) > (cond > [(null? remaining-list) > '()] > [(equal-proc (car remaining-list) unwanted) > (loop (cdr remaining-list))] > [else > (cons (car remaining-list) > (loop (cdr remaining-list)))]))))) > ~~~~ > > ~~~~TEST~~~~ > (let ([a '(9 10)] > [b '(9 10)]) > (test-equal "make-multiple-list-remover-03" > `(1 2 (3) (4) ,a) > ((make-multiple-list-remover eq?) > `(a b (c) (d) ,a) b))) > ~~~~ > > I was wondering, why the test fails. I think (eq? ...) should not be > able to see the equivalence of both lists a and b, just like when > defined using (define ...). > > I can also run it in the REPL and see the difference: > > ~~~~ > (define a '(9 10)) > (define b '(9 10)) > ((make-multiple-list-remover eq?) > `(a b (c) (d) ,a) b) > $4 = (a b (c) (d) (9 10)) > > (let ([a '(9 10)] > [b '(9 10)]) > ((make-multiple-list-remover eq?) > `(a b (c) (d) ,a) b)) > $5 = (a b (c) (d)) > ~~~~ > > Somehow the bindings of let seem to be different from the bindings > created using define. What about using define inside let? > > ~~~~ > > ~~~~ > -- > repositories: https://notabug.org/ZelphirKaltstahl Somehow the bindings of let seem to be different from the bindings created using define. What about using define inside let? ~~~~ (let ([unrelated 'bla]) (define a '(9 10)) (define b '(9 10)) ((make-multiple-list-remover eq?) `(a b (c) (d) ,a) b)) $7 = (a b (c) (d)) ~~~~ So there the define usage also differs from when I use define on the top level. Perhaps that is the difference? On which level the bindings are defined? Regards, Zelphir -- repositories: https://notabug.org/ZelphirKaltstahl