<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/4.2.2">
</HEAD>
<BODY>
<BR>
<BLOCKQUOTE TYPE=CITE>
<PRE>
> But, now I have to had an attribute wich do not have to tested and I can't
> figure the best way out.
>
> Would I investigate with inspector or the equal<%> interface.
> Both ways, I don't know how to do this. The doc is pretty brief about that.
</PRE>
</BLOCKQUOTE>
<BR>
<BLOCKQUOTE TYPE=CITE>
<PRE>
Are you saying that there are fields in your object that you don't
want to be part of the equality test?
</PRE>
</BLOCKQUOTE>
<PRE>
Yes, that's exactly what I meant.
</PRE>
<BLOCKQUOTE TYPE=CITE>
<PRE>
If so, it does sound like implementing the equal<%> interface may give
you enough power to express that idea.
(<A HREF="http://docs.racket-lang.org/reference/objectequality.html">http://docs.racket-lang.org/reference/objectequality.html</A>)
</PRE>
</BLOCKQUOTE>
And that's exactly what I was struggling to.<BR>
<BR>
<BLOCKQUOTE TYPE=CITE>
<PRE>
Here's a small example:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang racket
(define ci-word%
(class* object% (equal<%>)
;; Initialization
(init-field word)
(super-new)
;; We define equality to ignore case:
(define/public (equal-to? other recur)
(string-ci=? word (get-field word other)))
;; The hash codes need to be insensitive to casing as well.
;; We'll just downcase the word and get its hash code.
(define/public (equal-hash-code-of hash-code)
(hash-code (string-downcase word)))
(define/public (equal-secondary-hash-code-of hash-code)
(hash-code (string-downcase word)))))
(define h (make-hash))
(hash-set! h (new ci-word% [word "foobar"]) 'value)
;; Of course, we expect this lookup to succeed:
(hash-ref h (new ci-word% [word "foobar"]))
;; but it will also match case-insensitively:
(hash-ref h (new ci-word% [word "FoOBaR"]))
</PRE>
</BLOCKQUOTE>
<BR>
Thank you very much. I tried all possibilities execept this way.<BR>
What I can't figured out is the end of the doc with :<BR>
<I>The <A HREF="http://docs.racket-lang.org/reference/objectequality.html#%28def._%28%28lib._racket/private/class-internal..rkt%29._equal%7E3c%7E25%7E3e%29%29">equal<%></A> interface is implemented with <A HREF="http://docs.racket-lang.org/reference/createinterface.html#%28form._%28%28lib._racket/private/class-internal..rkt%29._interface*%29%29">interface*</A> and <A HREF="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._%7E23%7E25kernel%29._prop%7E3aequal+hash%29%29">prop:equal+hash</A>.</I><BR>
I tought I had to implement the equal<%> interface myself.<BR>
<BR>
Thanks again for the help.
</BODY>
</HTML>