home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / object / 4659 < prev    next >
Encoding:
Text File  |  1992-12-24  |  3.3 KB  |  73 lines

  1. Newsgroups: comp.object
  2. Path: sparky!uunet!psinntp!afs!greg
  3. From: greg@afs.com (Gregory H. Anderson)
  4. Subject: Re: Equality
  5. Message-ID: <1992Dec24.183708.2261@afs.com>
  6. Sender: greg@afs.com
  7. Reply-To: greg@afs.com
  8. References: <1992Dec22.152021.4209@kei.is.s.u-tokyo.ac.jp>
  9. Date: Thu, 24 Dec 1992 18:37:08 GMT
  10. Lines: 61
  11.  
  12. In article <1992Dec22.152021.4209@kei.is.s.u-tokyo.ac.jp>  
  13. jeff@is.s.u-tokyo.ac.jp (Jeff McAffer) writes:
  14.  
  15. > > May two objects of different classes be equal?
  16. > Yes
  17.  
  18. Please explain how that could be. Just because they happen to be exactly  
  19. the same size, and happen to involve exactly the same instance variables,  
  20. which happen to contain the same values, are two objects from different  
  21. classes equal? In Objective-C, this would be prima facie impossible,  
  22. because the first instance variable is always 'isa', which points to the  
  23. class. If two objects were equal in the sense I just defined, they would  
  24. *have* to be members of the same class, or else their 'isa' pointer would  
  25. be different. Maybe I'm missing something?
  26.  
  27. Also, I would argue that an object is more than the sum and contents of  
  28. its ivars. I would expect 'equal' objects to respond to the same methods,  
  29. so I could use them interchangeably. Otherwise, something doesn't feel  
  30. right to me about the definition of equality. I guess I'm arguing that  
  31. both attributes and functional capabilities must be accounted for in  
  32. deciding the equality of objects.
  33.  
  34. > > May two objects be equal even if they don't respond to the same  
  35. protocol?
  36. > No but... I have been known to in the past, define equals based on a
  37. > subset of protocol.  That is , two object can be equal if they respond
  38. > to this subset and have the other equality properties I want.  Now I
  39. > would not claim that this is good or desireable.  It just was.
  40.  
  41. You just agreed with my last point, but in a less strict way. Even a  
  42. minimal subclass that involves new methods only is different, and I would  
  43. argue that these differences make its instances non-equal.
  44.  
  45. > > If they respond to the same protocol but have no common superclass
  46. > > which defines that protocol (i.e. protocol similarity is incidental)?
  47. > NO!  In general I do not find many places that I want to separate just
  48. > plain ole protocol (i.e., method name, arg count...) from the
  49. > semantics of the method.  Esssentially protocol for me includes a
  50. > detailed implementation independent description of what the method
  51. > does.  Hard to test at run time I know but darn useful when you are
  52. > programming.
  53.  
  54. No, but for a different reason. Aside from my 'isa' pointer objection  
  55. above, if two objects come down through two different hierarchies, then  
  56. even a common set of ivars and methods don't make them equal, because they  
  57. will potentially respond in different ways. In other words, there is no  
  58. greater likelihood they will act the same way as any two unrelated classes  
  59. that happen to implement the same method. If the action is not the same,  
  60. then the objects are not equal, even if their ivars and method namespaces  
  61. superficially resemble each other.
  62.  
  63. --
  64. Gregory H. Anderson          | Thus spake the master programmer: 
  65. Master Programmer / Manager  | "Let the programmers be many and  
  66. Anderson Financial Systems   | the managers few; then all will be 
  67. greg@afs.com  (Nextmail OK)  | productive." -- Tao of Programming
  68.