emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#21855: closed (eq?)


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#21855: closed (eq?)
Date: Fri, 24 Jun 2016 15:32:02 +0000

Your message dated Fri, 24 Jun 2016 17:31:11 +0200
with message-id <address@hidden>
and subject line Re: bug#21855: eq?
has caused the debbugs.gnu.org bug report #21855,
regarding eq?
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
21855: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21855
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: eq? Date: Sat, 07 Nov 2015 13:58:48 +0100 User-agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-unknown-linux-gnu)
So I wanted to try out gnu guix and thus make myself more familiar with
guile first. While running some tests I encountered a problem/bug with eq?:

$ guile -v
guile (GNU Guile) 2.1.1

$ guile
scheme@(guile-user)>
(define (multirember a lat)
  (cond
   ((null? lat) '())
   ((eq? (car lat) a) (multirember a (cdr lat)))
   (else (cons (car lat) (multirember a (cdr lat))))))
   
scheme@(guile-user)> (multirember '(a b) '(x y (a b) z (a b)))
$1 = (x y z)

So why does guile return (x y z)? I expected (x y (a b) z (a b)). I know
eq? should only be used with symbols (and thus this example is more
theoretical) but nevertheless the return value is not right, since (eq?
'(a b) '(a b)) returns #f (Btw same in guile 2.0.11).



--- End Message ---
--- Begin Message --- Subject: Re: bug#21855: eq? Date: Fri, 24 Jun 2016 17:31:11 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
On Sun 08 Nov 2015 11:23, <address@hidden> writes:

> On Sat, Nov 07, 2015 at 01:58:48PM +0100, Atticus wrote:
>> So I wanted to try out gnu guix and thus make myself more familiar with
>> guile first. While running some tests I encountered a problem/bug with eq?:
>> 
>> $ guile -v
>> guile (GNU Guile) 2.1.1
>> 
>> $ guile
>> scheme@(guile-user)>
>> (define (multirember a lat)
>>   (cond
>>    ((null? lat) '())
>>    ((eq? (car lat) a) (multirember a (cdr lat)))
>>    (else (cons (car lat) (multirember a (cdr lat))))))
>>    
>> scheme@(guile-user)> (multirember '(a b) '(x y (a b) z (a b)))
>> $1 = (x y z)
>> 
>> So why does guile return (x y z)? I expected (x y (a b) z (a b)). I know
>> eq? should only be used with symbols (and thus this example is more
>> theoretical) but nevertheless the return value is not right, since (eq?
>> '(a b) '(a b)) returns #f (Btw same in guile 2.0.11).
>
> Hm. As far as I know (eq? '(a b) '(a b)) is not *guaranteed* to evaluate
> to #f. The implementation might be free to re-use things it "knows" to be
> constant (I might be wrong, though).

Tomas is correct; within one compilation unit, constant literals will be
deduplicated.  That means that within one compilation unit, (eq? '(a b)
'(a b)) will indeed be #t.... yarggghhhh.... but:

  scheme@(guile-user)> (eq? '(a b) '(a b))
  $1 = #f
  scheme@(guile-user)> ,optimize (eq? '(a b) '(a b))
  $2 = #f

Evidently the optimizer is doing the compare at compile-time, which it
is allowed to do, and at compile-time the values are actually distinct.
I will see if I can fix that.  However Tomas' logic is impeccable :)

Closing as things are all working fine, I think.

Cheers,

Andy


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]