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

From: Alan Watson (alan at alan-watson.org)
Date: Tue Oct 7 14:13:24 EDT 2008

> Fundamental?  No, eqv? is basically eq? with a tweak for numbers.  It
> does not perform extensional comparisons on any other immutable data
> structures such as immutable lists, immutable strings, uninterned
> symbols, or all kinds of other things that can only be distinguished
> by eq? or eqv?.

Standard Scheme does not have real immutable lists, real immutable  
strings, or uninterned symbols. (If it did, I would agree that eqv?  
should compare them extensionally.)

When I say that eq? is not the fundamental identity predicate, I do  
not mean to say that you cannot write eqv? in terms of eq? and the  
rest of Scheme. I mean to say that if you want a predicate that tells  
you if two data structures are "fundamentally identical", you should  
use eqv? not eq?. By "fundamentally identical", I mean  
"indistinguishable except possibly by using eq? because the only  
differences detected by eq? but not eqv? are accidents of the  
implementation".

Let's imagine we have two identity predicates on numbers. One is the  
standard "=" and the other is "maybe-=", which returns the same as "="  
except when one or both of the arguments is zero, in which case it can  
return either #t or #f. Which would you throw out of the language?

Regards,

Alan

P.S. My "maybe-=" procedure is not completely contrived; think of IEEE  
floating-point formats and comparing either the bits or the values  
according to the IEEE equality predicate.
-- 
Alan Watson
http://www.alan-watson.org/



Posted on the users mailing list.