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

  1. Path: sparky!uunet!gatech!europa.asd.contel.com!howland.reston.ans.net!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!olivea!charnel!sifon!newsflash.concordia.ca!grogono
  2. From: grogono@cs.concordia.ca (Peter Grogono)
  3. Newsgroups: comp.object
  4. Subject: Re: Object hidden state and side effects
  5. Message-ID: <BzMo4u.791@newsflash.concordia.ca>
  6. Date: 21 Dec 92 21:10:06 GMT
  7. References: <1992Dec16.65250.10645@kei.is.s.u-tokyo.ac.jp> <1992Dec16.175126.14968@midway.uchicago.edu> <BzIFGp.K7@cs.uiuc.edu>
  8. Sender: usenet@newsflash.concordia.ca (USENET News System)
  9. Organization: Computer Science, Concordia University, Montreal, Quebec
  10. Lines: 31
  11. Nntp-Posting-Host: concour.cs.concordia.ca
  12.  
  13. In article <BzIFGp.K7@cs.uiuc.edu> johnson@cs.uiuc.edu (Ralph Johnson) writes:
  14. >The difference between an "object" and a "value" seems to be that for
  15. >a value, equality can be implemented by bit comparison of the things,
  16. >while objects can only use identity of addresses in memory or else
  17. >require a user-supplied function.  Isn't this just a result of immutability?
  18.  
  19. This is misleading because equality is (almost) orthogonal to the
  20. object/value distinction.  Graphs, with edges represented by pointers,
  21. may be values, but you would not want to compare them bit-by-bit in
  22. an equality test, because "equality" in this case should mean
  23. "isomorphic" for most applications.
  24.  
  25. I agree that objects are "equal" (actually "identical") if they have
  26. the same address, and that this is often a useful test.
  27.  
  28. The underlying problem is the difference between intensions and
  29. extensions. As a general rule, we compute with intensions but we
  30. want to compare extensions. The strings "2+2" and "1+3" have the
  31. same extensional value, under a suitable interpretation, but are not
  32. equal strings. If we convert them to the integers 4 and 4, we achieve
  33. equality, but that is mere good fortune, because we are
  34. still working with intensions (or representations). The whole point
  35. of semantic theories is to show that we can obtain correct
  36. extensional results while working with intensions.
  37.  
  38. IMHO, there is no suitable default for equality in an OO language.
  39. The language should provide a few simple tests, such as bit
  40. comparison and pointer comparison, but it is the responsibility of
  41. each class to provide a criterion for equality of its instances.
  42.  
  43. Peter
  44.