[plt-scheme] When does eqv? differ from eq? , from equal?

From: Alan Watson (alan at alan-watson.org)
Date: Mon Oct 6 18:53:34 EDT 2008

Assuming that "it takes time" means "is not a pointer comparison", then:

> it takes time to equate 10000000000 with 10000000000

Not with 61-bit fixnums. :-)

> but not (list 1 2 3) with (list 1 2 3)

Not if all exact integers are represented as bignums or otherwise  
boxed. :-)

> However, we can observe the differences in
> space consumption between a list of bignums that are all eq? (not much
> space used), versus a list of bignums that are all eqv? but not eq?
> (potentially lots of space used).

Whether two numerical values that are eqv? are also eq? depends on the  
implementation. If an implementation hashes boxed numerical values,  
they can easily be eq? even if they are the result of different  
expressions. And I am not making this up; MACLISP did precisely this.

> I only use eq? when I really, really mean it

But what do you really, really mean? For any arguments for which eq?  
gives a reliable result (by which I mean, a result that does not  
depend on the implementation), eqv? will give you the same result.

Regards,

Alan
-- 
Alan Watson
http://www.alan-watson.org/



Posted on the users mailing list.