home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!pagesat!spssig.spss.com!uchinews!alex!dave
- From: dave@alex.uchicago.edu (Dave Griffith)
- Newsgroups: comp.object
- Subject: Equality
- Message-ID: <1992Dec21.184405.2215@midway.uchicago.edu>
- Date: 21 Dec 92 18:44:05 GMT
- Sender: news@uchinews.uchicago.edu (News System)
- Organization: University of Chicago
- Lines: 47
-
- So just what exactly do you all mean when you say "equality". If it's just
- another binary predicate, why bother to call it equality? If not, what
- semantic properties should it have? The recent object/value discussion brought
- up some examples which cause me to question my preconceived notions. I will
- below attempt to list those notions, in hope the group will provide useful
- comments. Throughout the following, "object" is used as in current OO
- languages, to represent both "objects" and "values".
-
- 1) Equality should be reflexive.
- I thought this was obvious, but IEEE754 may provide a counterexample.
-
- 2) Equality should be symettric.
- 3) Equality should be transitive.
- 4) Substitution of equals for equals should give equals.
- 5) If two objects are equal at one point in program execution, they should be
- equal at all points.
- 6) Assignment should respect equality. (Assuming no side-effects, after
- executing x:=a; it should be true that x=a.
- 7) If your parameter passing model is based on assignment, 6) should hold
- mutatis mutandi.
- 8) If two objects are equal, they should be behaviourally indistinguishable.
- The converse need not hold, but often will.
- 9) Two sets A,B are equal iff for_all(x:A)there_exists(y:B) such y=x, and
- vice versa.
-
- Given mutable objects, identity was the only practical definition I found
- which would support all of the above. However, identity is not a practical
- equality definition for all objects we wish to program with (vis, integers).
- In these cases, if immutability holds, users may be able to define equality
- in ways which satisfy the above, and there are good reasons to let them try.
-
- This is comp.object, so presumably when people talk equality here, they don't
- mean bitwise or address equality, although these may be used as implementation
- techniques. The following questions also arise do to object orientation:
- May two objects of different classes be equal? May two objects be equal even
- if they don't respond to the same protocol? If they respond to the same
- protocol but have no common superclass which defines that protocol
- (i.e. protocol similarity is incidental)?
-
- If programmers view equality as just another binary predicate, perhaps I
- should come up with a different name for the operation I need. Any
- suggestions?
-
- --
- Dave Griffith, Information Resources, University of Chicago,
- Department of Surgery dave@alex.bsd.uchicago.edu
- A man's best friend is his dogma.
-