home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / object / 4626 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  2.8 KB

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