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

Re: [Scheme-reports] eq? considered harmful.



On 08/13/2012 05:21 PM, John Cowan wrote:
> Ray Dillinger scripsit:
>
>> eq's behavior is strictly less specified than eqv?s behavior.
>> That means it is LESS discriminating, not more discriminating.
>
> It is more discriminating in the same sense that eqv? is more
> discriminating than equal?, namely that it can distinguish between a 2
> and another 2, whereas eqv? cannot.  By the same token, (a b c) and (a
> b c) are not eqv? (in general), but they are equal?, because equal? is
> less discriminating than eqv?.

I think you're right that this is what the authors meant by "more 
discriminating", but I tend to agree with Ray that this choice of words 
is likely to confuse and mislead readers, because the additional 
"discrimination" provided by 'eq?' conveys no useful information.

The fact that (a b c) and another (a b c) are not 'eqv?' is useful and 
meaningful information, because it implies that calling 'set-car!' on 
one will not affect the other, and this is guaranteed by the standard. 
In contrast, if two numbers are 'eqv?', the result of 'eq?' provides no 
useful information whatsoever.

As Ray said, 'eq?' is just a performance hack, nothing more.  'eq?' and 
'eqv?' are both approximations of the operational equivalence relation. 
  The only difference is that 'eq?' is defined in fewer cases than 'eqv?'.

'equal?' has an entirely different meaning, with different use cases.

      Mark

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports