home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / object / 4566 < prev    next >
Encoding:
Text File  |  1992-12-17  |  4.8 KB  |  88 lines

  1. Newsgroups: comp.object
  2. Path: sparky!uunet!europa.asd.contel.com!emory!swrinde!sdd.hp.com!spool.mu.edu!uwm.edu!linac!uchinews!alex!dave
  3. From: dave@alex.uchicago.edu (Dave Griffith)
  4. Subject: Re: Object hidden state and side effects
  5. Message-ID: <1992Dec17.033522.2857@midway.uchicago.edu>
  6. Sender: news@uchinews.uchicago.edu (News System)
  7. Organization: University of Chicago
  8. References: <1992Dec16.65250.10645@kei.is.s.u-tokyo.ac.jp> <1992Dec16.175126.14968@midway.uchicago.edu> <knight.724557211@cunews>
  9. Date: Thu, 17 Dec 1992 03:35:22 GMT
  10. Lines: 76
  11.  
  12. In article <knight.724557211@cunews> knight@mrco.carleton.ca (Alan Knight) writes:
  13. >In <1992Dec16.175126.14968@midway.uchicago.edu> dave@alex.uchicago.edu (Dave Griffith) writes:
  14. >
  15. >>In article <1992Dec16.65250.10645@kei.is.s.u-tokyo.ac.jp> jeff@is.s.u-tokyo.ac.jp writes:
  16. >>>In article <1992Dec15.014420.6604@midway.uchicago.edu> dave@alex.uchicago.edu (Dave Griffith) writes:
  17. >
  18. >> ... "Objects" as I have
  19. >>been using the term use reference semantics.  Two objects are only equal if
  20. >>they are identical.  "Values" use copy semantics for assignment. (What they
  21. >>use for equality semantics is a deeper and IMHO more interesting question, but 
  22. >>I digress.)  How these semantics are actually implemented is a implementation
  23. >>decision and should not be considered here.  
  24. >
  25. >This definitely seems to be the root of the confusion. You mean
  26. >something different by "object" than I do, and I expect than Jeff
  27. >McAffer or Jan Steinman do.  If you call something an object only if
  28. >equality and identity are the same operation, then most OO langauges
  29. >already support the distinction being called for, since the equality
  30. >operation can be defined to be anything you like. This is certainly
  31. >the case for "value objects" in Smalltalk, such as Booleans, Numbers,
  32. >Symbols, etc. Somebody just posted that the same thing is true in
  33. >Eiffel. Maybe you can't do it in C++, but that's a whole other debate.
  34. >
  35.  
  36. It most certainly is not true for Eiffel.  Eiffel goes to great lengths
  37. to make a distinction between reference and copy semantics, so that they
  38. can be pretty arbitrarily mixed and matched line by line throughout the
  39. code.  There is no enforced concept of immutability. There may be uses for 
  40. this sort of thing, including implementation of values, but it is most 
  41. definitely not a direct, enforced way of declaring a value.
  42.  
  43. Redefining the equality operation is useful, but again is not all that is 
  44. necessary for the concept "value".  One must also have immutability.
  45.  
  46. As for Smalltalk, you've just listed a bunch of system-declared values.
  47. We are talking about user declared values.  Anyone can hack special cases
  48. into their system-defined libraries.  Certainly it is done in all of the 
  49. languages you've mentioned here.
  50.  
  51. In any case, you quoted me out of context.  It certainly isn't the case
  52. that the only distinction between objects and values is assignment semantics.
  53. It is just one of the distinctions.
  54.  
  55. >>>about it.  They are just objects to which I can send messages, pass as
  56. >>>parameters...  They have a protocol... and allow only those operations
  57. >>>that are in line with their "essential sameness"
  58. >
  59. >>But most languages have no way to _enforce_ the requirement that they "only
  60. >>allow operations that are in line with their essential sameness".  They
  61. >>treat their builtin classes as "special", and don't allow programmer defined
  62. >>classes to be defined as special in the same way.  It would be useful in C++
  63. >>for instance to define a Bignum class which didn't allow the programmer
  64. >>to set 3 equal to 5, even if that Bignum class is eventually subclassed.  
  65. >>Subclassing can blow away the original programmers intent of immutability, 
  66. >>with possibly disastrous effects on program correctness.
  67. >
  68. >The only "special" distinction in Smalltalk is between SmallIntegers
  69. >and everything else.  The distinction is effectively invisible in
  70. >normal use.  Also, what you are asking for is possible in C++ (but not
  71. >in Smalltalk). In C++, private class members are not visible to
  72. >subclasses. If you don't provide any destructive functions then they
  73. >cannot be added when you subclass. I think you can circumvent this by
  74. >writing "friend" functions, but that's an explicit mechanism provided
  75. >to circumvent the language restrictions in the name of performance.
  76. >
  77.  
  78. Close, but not quite.  Invisible certainly implies immutable (you can't 
  79. change what you can't see), but the converse fails.  C++ (unless Bjarne has
  80. changed it yet again) does not provide a way of making an instance variable
  81. visible but immutable.  (Of course, any C derived language is going to have
  82. extreme problems with immutability anyway...)
  83.  
  84. -- 
  85. Dave Griffith, Information Resources, University of Chicago,
  86. Department of Surgery                       dave@alex.bsd.uchicago.edu
  87. Oh, by the way, I almost forgot.  Godot called.  He said he'd be late.
  88.