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

  1. Newsgroups: comp.object
  2. Path: sparky!uunet!spool.mu.edu!yale.edu!ira.uka.de!chx400!bernina!neptune!santas
  3. From: santas@inf.ethz.ch (Philip)
  4. Subject: Re: Equality
  5. Message-ID: <1992Dec22.234147.480@neptune.inf.ethz.ch>
  6. Sender: news@neptune.inf.ethz.ch (Mr News)
  7. Nntp-Posting-Host: ru8.inf.ethz.ch
  8. Organization: Dept. Informatik, Swiss Federal Institute of Technology (ETH), Zurich, CH
  9. References: <1992Dec21.184405.2215@midway.uchicago.edu> <BzoAD8.By6@newsflash.concordia.ca> <1992Dec22.183803.16421@midway.uchicago.edu>
  10. Date: Tue, 22 Dec 1992 23:41:47 GMT
  11. Lines: 91
  12.  
  13. In article <1992Dec22.183803.16421@midway.uchicago.edu> dave@alex.uchicago.edu (Dave Griffith) writes:
  14. > grogono@cs.concordia.ca (Peter Grogono) writes:
  15. >>dave@alex.uchicago.edu (Dave Griffith) writes:
  16. >>> .......
  17. >>>8) If two objects are equal, they should be behaviourally indistinguishable.
  18. >>>   The converse need not hold, but often will.
  19. >>>9) Two sets A,B are equal iff  for_all(x:A)there_exists(y:B) such y=x, and
  20. >>>   vice versa.
  21. >>>
  22. >>>Given mutable objects, identity was the only practical definition I found
  23. >>>which would  support all of the above.  However, identity is not a practical
  24. >>>equality definition for all objects we wish to program with (vis, integers).
  25. >>
  26. >>I do not see how "identity" supports #9. In principle, A=B, where A and
  27. >>B are sets, should mean that A and B have the same members, even if the
  28. >>representations of A and B are distinct in memory and may be different
  29. >>data structures. I do not see how an equality test of this kind can be
  30. >>built-in to a language, and this was my reason for saying that equality
  31. >>must be user-defined in general.
  32. >
  33. >For all of the above to hold for set objects, they must be
  34. >immutable anyway (#5 and #8, as well as the basic mathematical idea of set),
  35. >and I've never expressed any disagreement with user-defined equality for
  36. >immutable objects.  If you want to test mutable "sets" to see whether they
  37. >have the same members, but I'm not sure with calling such a test equality,
  38. >unless equality is just another binary predicate.
  39.  
  40. Although "mutable sets" is an oxymoron, and although types are _not_
  41. sets, equality is not the same as identity, and should not be like
  42. that, if you want to deal with non-trivial applications.
  43.  
  44. Peter makes a good point concerning the separation of behaviour from
  45. representation: if you really want to separate them, you have to 
  46. separate equality from identity.
  47.  
  48. In other words, we come pretty close to the concepts of _isomorphism_
  49. and _canonicality_: the former refers to types or sets, the latter to
  50. their elements or instances respectively.
  51.  
  52. If you wish to combine _equality_ with _identity_, then a combination
  53. of the two above helps a lot: if _any_ time we construct an object
  54. which happens to be _isomorphic_ to one previously stored, the 
  55. constructor function simply returns the same location in memory as 
  56. the first. This approach introduces _canonicality_ in a programming
  57. environment: two equal expressions are represented by pointers to one
  58. _canonical_ data structure. 
  59.  
  60. Since nothing is so simple in this world, in order to be consistent
  61. with our models, we need _algorithms_ to _convert_ an expression/value
  62. to a canonical form (say goodbye to "mutability"): the deriving 
  63. representation must be _canonical_ with respect to a _class_ of functions, 
  64. ie. two _mathematically_ equivalent_ forms in that class, are 
  65. algorithmically mapped to identical _unique_ forms. Example:
  66.  
  67. x, y : Integer
  68. x-x == y-y == 0
  69.  
  70. The canonical form above is the 0:Integer, ie. we came to  a canonical
  71. form in respect to _implementation_ (remember that we started from
  72. _behaviour_)
  73.  
  74. These things are definitely not new, and they have been used since _years_
  75. with _much_ success in computer algebra systems like Maple and in
  76. general purpose languages like Lisp: Signature Hashing is by no means
  77. a new term in the CS community.
  78.  
  79. If one still wishes to program with side-effects,  then you have
  80. to be more careful with the _destructive_ operations. In general
  81. there is no reason to impose a paradigm which forces the user
  82. to use side-effects in the 90% of the situations in which he does
  83. not need them: given a good algorighm for generating canonical forms
  84. for each class, there is _no_ need at all to care about efficiency
  85. of "mutability", which is much _less_ than the 10% of the _whole_ work.
  86.  
  87. Equality is not something which you can sacrifice for _forcing_
  88. the user to write ugly and _inneficient_ programs full with side-effects 
  89. and unexpected behaviour. For sure you _need_ mutable objects, _but_ they 
  90. are a _very_ small minority in a _decent_ program.
  91.  
  92. Philip Santas
  93.  
  94.   "In an evolving universe those who stand still are really moving backwards"
  95. --------------------------------------------------------------------------------
  96. email: santas@inf.ethz.ch                 Philip Santas
  97. Mail: Dept. Informatik                   Inst. of Scientific Computation
  98.       ETH-Zentrum              Swiss Federal Institute of Technology
  99.       CH-8092 Zurich                       Zurich, Switzerland
  100.       Switzerland
  101. Phone: +41-1-2547478
  102.       
  103.  
  104.