From: Ram Bhamidipaty
Subject: eql and defstruct
Date: 
Message-ID: <0a792e94-4899-4760-ad17-651ceac6006e@p10g2000prf.googlegroups.com>
If I have this:

(defstruct thing
  (part1 0)
  (part2 0))

Is there a way to specify a function that can be used
as a compare function - and have it get picked up by
equal or eql?

For example how would I create a hash
table and use a structure as a key? In this case I
would like any two thing-p objects to be equal if
their part1 and part2 slots are equal.

Or would I need to create my own hash table to do that?

-Ram

From: Pascal J. Bourguignon
Subject: Re: eql and defstruct
Date: 
Message-ID: <87od2e864u.fsf@hubble.informatimago.com>
Ram Bhamidipaty <·······@gmail.com> writes:

> If I have this:
>
> (defstruct thing
>   (part1 0)
>   (part2 0))
>
> Is there a way to specify a function that can be used
> as a compare function - and have it get picked up by
> equal or eql?

Do you really need EQUAL or EQL?
EQUALP works recursively on structures.


> For example how would I create a hash
> table and use a structure as a key? In this case I
> would like any two thing-p objects to be equal if
> their part1 and part2 slots are equal.

What about EQUALP?


> Or would I need to create my own hash table to do that?

On some implementation (such as clisp), as an extension, you may use
your own equal function with hash-table.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

THIS IS A 100% MATTER PRODUCT: In the unlikely event that this
merchandise should contact antimatter in any form, a catastrophic
explosion will result.
From: Ram Bhamidipaty
Subject: Re: eql and defstruct
Date: 
Message-ID: <5feab121-73d4-4cb1-a538-4dcfa810f571@v16g2000prc.googlegroups.com>
On Sep 23, 10:28 pm, ····@informatimago.com (Pascal J. Bourguignon)
wrote:
> Ram Bhamidipaty <·······@gmail.com> writes:
> > If I have this:
>
> > (defstruct thing
> >   (part1 0)
> >   (part2 0))
>
> > Is there a way to specify a function that can be used
> > as a compare function - and have it get picked up by
> > equal or eql?
>
> Do you really need EQUAL or EQL?
> EQUALP works recursively on structures.
>
> > For example how would I create a hash
> > table and use a structure as a key? In this case I
> > would like any two thing-p objects to be equal if
> > their part1 and part2 slots are equal.
>
> What about EQUALP?
>
> > Or would I need to create my own hash table to do that?
>
> On some implementation (such as clisp), as an extension, you may use
> your own equal function with hash-table.
>


Thank you! I did not now about equalp. This works for me.

-Ram