On Mar 1, 2011, at 16:20 , Willem Broekema wrote:
On Tue, Mar 1, 2011 at 12:18 PM, Marco Antoniotti marcoxa@cs.nyu.edu wrote:
Hi here is the second iteration for the "equality and comparison" proposal.
Marco,
I'm interested in this proposal as the need for custom equality predicates and hash tables has come up in my work. Here's feedback on the version you just sent:
- These example results seem wrong:
cl-prompt> (EQUALS "FOO" "Foo") T cl-prompt> (EQUALS "FOO" "Foo" :case-sensitive-p nil) NIL
Thanks, I will fix it.
- That EQUALS (a array) (b array) looks at array-total-size instead of
the exact dimensions is surprising to me.
I guess I was lazy. What would be a fix for this?
- Why does this return error, why is it not applying the (T T) method
that would return /= ?
cl-prompt> (COMPARE (make-array 3 :initial-element 0) (vector 1 2 42)) Error: Uncomparable objects #(0 0 0) and #(1 2 42).
Sorry. Bad cut'n'paste. It shoudl return /=.
- It seems EQUALS and HASH-CODE are not usable in combination for hash
tables, if the keys are numbers (sxhash of = numbers of different types, like 2 and 2.0, can be different) or arrays (sxhash could look at dimensions, not just array-total-size). That would be unfortunate.
The original proposal did not include HASH-CODE and I am ambivalent about it. In general, there is no way even in Java to enforce the protocol; so HASH-CODE should just be thought as a hook for possible future use. Of course, relying on SXHASH is dubious to start with, given what its entry says and considering that there is not even a guarantee that GETHASH uses it (AFAIK).
If this is too controversial, it should be removed.
Cheers -- Marco Antoniotti