[plt-scheme] Re: When does eqv? differ from eq? , from equal?
On Tue, Oct 7, 2008 at 8:29 AM, Alan Watson <alan at alan-watson.org> wrote:
>> And eqv?, the function that started this
>> whole topic, is useless as near as I can tell, since it is defined to
>> be eq? unless you know the values you're comparing are numbers or
>> characters (or a handful of "empty" values) in which case you're
>> better off using a type-specific comparison function.
>
> Um, eqv? is the fundamental identity predicate for data structures in
> Scheme. That is, if two data structures are eqv?, they cannot be
> distinguished by any finite composition of standard Scheme procedures except
> eq?, which, as I have said, is cheating.
>
> So, eqv? seems pretty useful to me. Or, like Shriram, do you also never use
> case? :-)
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?. If you want something truly fundamental, you have to
go farther than eqv?. There's a broad spectrum between eq? and a
"fundamental" comparison that equates anything that cannot be
distinguished by other means, and eqv? is only one tiny step away from
eq? toward the other end.
As for case, I rarely use it; when I do, I'd be happy to have it use equal?.
--
Carl Eastlund