Re: is_equal implies same_type?



In message <483b1886$0$27453$9b4e6d93@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
Georg Bauhaus <see.reply.to@xxxxxxxxxxxxxxxxxx> wrote:

Simon Willcocks wrote:
I was just wondering; can anyone give me a realistic example of two objects
which could be considered equal, but are of different types?

Any object that is just as good as some others, with respect
to a given use case involving these objects.

I'm not sure I follow you here, but I think you are describing what objects
can be compared to each other, in which case I didn't make myself clear,
sorry. I am looking for an example where a comparison feature (equal or
is_equal) returns True although the two objects being compared are of
different types.

I have used programmer defined equality (and "less than") when
storing objects in sets for the purposes of a simple graph algorithm.
Granted, these were rooted at the same base type, but still
the analog of CIRCLE was just as good as the analog of TRIANGLE.

OK, but a CIRCLE would never be equal to a TRIANGLE, would it?

Another case is when I want to know whether any two objects
are different, and not use reference equality for the comparison
(thinking of persistent featuers, say).
I then have two types inherit deferred UNIQUE_ID which
happens to be a factory of GUIDs, and any object other
than Void is equal to itself only, no matter what type.

I don't see the difference between that and reference equality, sorry.
However, if an object is only equal to itself, then objects can still only
be equal if they are the same type.

Thanks for replying.

Simon

--
ROLF - The RISC OS Look and Feel on Linux.
http://stoppers.drobe.co.uk
http://ro-lookandfeel.blogspot.com/
.


Loading