On 15 Feb 2011, at 15:21, Marco Antoniotti wrote:

On Feb 15, 2011, at 14:36 , Attila Lendvai wrote:

- The idea that COMPARE returns symbols also seems weird to me. Wouldn't it be better to return numbers (-1, 0, +1 or NIL)? Can't immediately tell why, though.


you need to return well-known identities that communicate the result.
-1,0,+1 are the easy way for well-known identities in C. in CL,
symbols provide a much nicer framework to deal with well-known
identities IMO.

That was the thinking.

OK.

- Shouldn't there also be a hash-code generic function that can be specialized alongside AEQUALIS? This also exists in Java and C#, and could make this immediately more useful (and would be much harder to add later as an afterthought). Many CL implementation add an :sxhash option to make-hash-table, where such a hash-code function could be used.


a big +1 for the above.

You should but:

  • As in Java (and FWIU in C#) there are no "easy" ways (for an appropriate definition of "easy") to enforce the protocol.
  • What would be the default?  Something like

(defmethod hash-code ((x t)) (sxhash x))


If you think so, I can add it to the doc.  Always with the caveat that there is no way to enforce the relationship between equality and hashing.

Yes, that's an important remark. I nevertheless think it's important, because then people have at least a place to hang their hat on.

The default implementation for hash-code looks good to me.

Marco

PS.  Yeah.  AEQUALIS is very Latin :)  Any synonym?  I will just vote against EGAL, which I really don't like :)

The good names are all taken, and I'm against adding a "?" to names in Common Lisp. ;)

What about "EQUIVALENT" or "EQUIV", or "EQUIVP"?


Pascal

-- 
Vrije Universiteit Brussel
Software Languages Lab
Pleinlaan 2, B-1050 Brussel, Belgium