home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / object / 4605 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  4.0 KB

  1. Path: sparky!uunet!noc.near.net!hri.com!spool.mu.edu!uwm.edu!linac!uchinews!alex!dave
  2. From: dave@alex.uchicago.edu (Dave Griffith)
  3. Newsgroups: comp.object
  4. Subject: Re: Object hidden state and side effects
  5. Message-ID: <1992Dec20.155809.14236@midway.uchicago.edu>
  6. Date: 20 Dec 92 15:58:09 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: news@uchinews.uchicago.edu (News System)
  9. Organization: University of Chicago
  10. Lines: 65
  11.  
  12. In article <BzIFGp.K7@cs.uiuc.edu> johnson@cs.uiuc.edu (Ralph Johnson) writes:
  13. >
  14. >In article <1992Dec16.65250.10645@kei.is.s.u-tokyo.ac.jp> jeff@is.s.u-tokyo.ac.jp writes:
  15. >
  16. >>I am really at a loss here.  What exactly (in concrete real terms) do
  17. >>you expect people to do differently when using true for example once
  18. >>it is recognized as a value and not an object?
  19. >
  20. >dave@alex.uchicago.edu (Dave Griffith) writes:
  21. >
  22. >>Express their actual intent clearly and precisely, without requiring 
  23. >>unneccessary contortions to map their intent to a overly limitted language.
  24. >>But I've always been a dreamer.
  25. >
  26. >This does not seem to me to be an answer "in concrete real terms".
  27. >
  28. >The difference between an "object" and a "value" seems to be that for
  29. >a value, equality can be implemented by bit comparison of the things,
  30. >while objects can only use identity of addresses in memory or else
  31. >require a user-supplied function.  Isn't this just a result of immutability?
  32.  
  33. I've never said anything about bitwise comparison.  Equality on values might
  34. certainly be user defined.  Even in these cases it should have restrictions,
  35. e.g. it should be symmetric, reflexive, transitive, and substitutabilty of 
  36. equals for equals should hold in all cases.  Equality on objects would 
  37. be identity.  Identity of memory address might be an implementation of this, 
  38. although other implementations are certainly possible (think of distributed 
  39. and persistent environments).  Immutability of values is certainly necessary 
  40. for this to work.
  41.  
  42. >
  43. >>But most languages have no way to _enforce_ the requirement that they "only
  44. >>allow operations that are in line with their essential sameness".  
  45. >
  46. >Most languages have no way to enforce anything that is interesting.
  47. >We can't really enforce that a subclass provides the same behavior
  48. >as a superclass.  In C++, I can enforce that a virtual function will
  49. >return an integer, but not a positive integer (except by making a
  50. >class for positive integers).  I can enforce that a sort function
  51. >take a boolean valued binary function as a parameter, but not that
  52. >it provide a total ordering on the collection to be sorted.  We need
  53. >to improve the expressive power of our languages.  I think that trying
  54. >to solve this problem just by making a value/object distinction is like
  55. >applying a bandaid to someone who had a leg cut off.  
  56. >
  57.  
  58. This is a description of the current state of programming, when we were 
  59. discussing a perscription for possible future programming.  Actually it's not
  60. even all that accurate, as it relies on some confusion as to the definition
  61. of "enforce".  Eiffel (with the exclusion of a few egregious features like
  62. "undefine") can and does enforce that a subclass has the same behavior as
  63. a superclass.  Of course, it does this at runtime (solving these problems
  64. at compile time is undecidable), and it only does so with behaviour that
  65. the programmer specifically asserts (pre- and postconditions, class invariants).
  66. If the behaviour is different, a runtime exception is thrown.  Not perfect, 
  67. but probably the best that the halting problem will allow.  The positive
  68. integer example is enforce in the same way by Ada, of all things.  In any 
  69. case, the value/object distinction is certainly compile-time enforcable.
  70. As others in the discussion have pointed out, they do enforce the distinction
  71. by hand.
  72.  
  73. -- 
  74. Dave Griffith, Information Resources, University of Chicago,
  75. Department of Surgery                       dave@alex.bsd.uchicago.edu
  76. Become a sociopath.  We don't even have to sweat the big stuff.
  77.