home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / object / 5116 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  9.7 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!agate!doc.ic.ac.uk!warwick!uknet!gdt!aber!aberfa!pcg
  2. From: pcg@aber.ac.uk (Piercarlo Grandi)
  3. Newsgroups: comp.object
  4. Subject: Re: FAQ  Part 1 (of 2) [ identity and OO paradigm ]
  5. Message-ID: <PCG.93Jan27181613@csthor.aber.ac.uk>
  6. Date: 27 Jan 93 18:16:13 GMT
  7. References: <1993Jan13.061114.18430@netcom.com> <PCG.93Jan19234945@decb.aber.ac.uk>
  8.     <1993Jan22.004305.16275@netcom.com>
  9. Sender: news@aber.ac.uk (USENET news service)
  10. Organization: University College of Wales, Aberystwyth
  11. Lines: 211
  12. In-Reply-To: objsys@netcom.com's message of 22 Jan 93 00: 43:05 GMT
  13. Nntp-Posting-Host: thor.dcs.aber.ac.uk
  14.  
  15. >>> On 22 Jan 93 00:43:05 GMT, objsys@netcom.com (Bob Hathaway) said:
  16.  
  17. Hathaway> In article <PCG.93Jan19234945@decb.aber.ac.uk>, pcg@aber.ac.uk
  18. Hathaway> (Piercarlo Grandi) writes:
  19.  
  20. Hathaway> [On values and objects as procedural instances, across > 1 postings]
  21.  
  22. Hathaway> I haven't had time to look into these definitions in depth,
  23. Hathaway> but there is a good point to be made here.  You can view
  24. Hathaway> almost anything as anything else and can contort almost
  25. Hathaway> anything into anything else if you try hard enough.
  26.  
  27. No, not quite -- you cannot contort a procedure into a label or an
  28. object into a type definition. One can mask syntax, but the semantics
  29. are either similar/equivalent or not.
  30.  
  31. Hathaway> Just because you can view objects in a strict functional or
  32. Hathaway> procedural way
  33.  
  34. But I don't -- I am just *explaining* the fact that in all languages in
  35. the Simula 67 mould (C++, Eiffel, Smalltalk, ...) objects are indeed
  36. (persistent, usually) procedure instances and classes are the procedures
  37. they are instances of. This is not at all a procedural or functional
  38. view; it is the historically and practically correct view of mainstream
  39. OO programming constructs.
  40.  
  41. Hathaway> Now comes the problem of deciding which of these views should
  42. Hathaway> represent the canonical one.
  43.  
  44. This has been already decided by the designers of Simula 67 for us.
  45.  
  46. Hathaway> You give an example of a particular procedural view to
  47. Hathaway> objects, although besides being the most unnatural approach I
  48. Hathaway> could think of
  49.  
  50. Complain to Dahl & Nyjgaard and Strostrup and Meyer about that; they did
  51. it like that, I am merely reporting the fact.
  52.  
  53. Hatahway> Further, the proposed procedural approach seems to be
  54. Hathaway> the furthest from a natural approach I can see.  People think
  55. Hathaway> of objects as having structure and behavior (and more
  56. Hathaway> recursively, usually through inheritance) and this can be
  57. Hathaway> directly supported with a natural OO model.
  58.  
  59. Well, a closure defines state (the variables bound in the closure,
  60. usually called the attributes or members of the object) and behaviour
  61. (the procedures bound in the closure, usually called the method or
  62. member functions of the class). That's precisely the point.
  63.  
  64.  
  65. Hathaway> Nothing stating that an object is an instance of its
  66. Hathaway> constructor.
  67.  
  68. No, no, the constructor is the _body_ of the procedure/class, it is not
  69. the procedure/class itself. So objects are instances of the
  70. procedure/class, and their state is initialized by the body of the
  71. procedure/class.
  72.  
  73. Hathaway> Smalltalk places the constructor in its metaclasses
  74.  
  75. The metaclasses are "just" the reflectively reified symbol table entries
  76. that describe the procedure/class.
  77.  
  78. Hathaway> and C++ places them in classes as a special member; just one
  79. Hathaway> among many.
  80.  
  81. Ah, in C++ the disguise of the procedure body as the constructor is most
  82. transparent. Just two points:
  83.  
  84. * the constructor is kind-of a static member (per-class, not
  85.   per-object) and is *untyped*.
  86.  
  87. * by explicit decision by Stroustrup, constructors are invoked
  88.   with the same syntax as Simula 67 classes.
  89.  
  90. A literal equivalence:
  91.  
  92.   class complex {        CLASS complex;
  93.     float re, im;          REAL re,im;
  94.     complex(float re,im)      PROCEDURE init(i_re,i_im)
  95.     : re(re), im(im) {}            REAL i_re,i_im;
  96.   }                  BEGIN re := i_re; im := i_im; END
  97.                 BEGIN END;
  98.  
  99.   complex *i            REF (complex) i;
  100.     = new complex(0.0,1.0);      i :- NEW complex; i.init(0.0,1.0);
  101.  
  102. The Simula 67 notation on the right is a bit opaque, just like the C++
  103. notation on the left; once would rather write, more naturally:
  104.  
  105.   CLASS complex(re,im)
  106.     REAL re,im;
  107.   BEGIN END;
  108.  
  109.   REF complex i;
  110.     i :- NEW complex(0.0,1.0);
  111.  
  112. Now, if you cannot see the substantial, relevant, equivalence of all
  113. three versions, it's not my fault.
  114.  
  115. Hathaway> Your proposed procedural view is just so much further from the
  116. Hathaway> truth.  If you want to implement your objects or even present
  117. Hathaway> your proposed procedural view
  118.  
  119. A disclaimer here: this is not *my* _proposed_ view. This is how Dahl
  120. and Hoare describe Simula 67, and how in fact all languages derived from
  121. Simula 67 are; I have posted the relevant quote from their article (the
  122. one that founded the whole subject of OO programming, and that so few
  123. people seem to have read) some time ago. But instead of just quoting it,
  124. it would be better to read the entire paper.
  125.  
  126. As to *my* views, I think, as I have remarked elsewhere, that the
  127. "Hierarchical program Structures" paper is insufficient and actually I
  128. quite disagree with its thrust, which is well summarized in its title.
  129.  
  130. Hathaway> You can change the meaning of value to be synonymous with
  131. Hathaway> objects
  132.  
  133. I don't do this, this is indeed the *fact*, that objects are values. An
  134. object is just, after all, a collection of bits, when looked at closely
  135. enough, i.e. a number that encodes some information. Nothing more,
  136. nothing less.
  137.  
  138. Hathaway> but I think this is confusing (I think you would use the term
  139. Hathaway> "dangerous" here) because values are equal regardless of
  140. Hathaway> identity
  141.  
  142. Why should values be always equal regardless of identity? Their
  143. denotations/extensions may be equal, but their addresses need not be. I
  144. can well have two cells that have as extension/denotation the number 3,
  145. but they may have different addresses. In side-effect free languages
  146. the address of values is not visible to the programmer, but this is
  147. quite different from implying as you say that in non side effect free
  148. languages identities do not arise.
  149.  
  150. Hathaway> and identities are always unique;
  151.  
  152. By definition :-).
  153.  
  154. Hatahway> there is an important distinction here in the object-oriented
  155. Hatahway> model because *both* are present.
  156.  
  157. Actually values can be EQUAL without being EQ in virtually all non side
  158. effect free languages, this has got nothing to do with OO.
  159.  
  160. Hatahway> (something which doesn't occur naturally in the functional
  161. Hatahway> model your proposal is natural for),
  162.  
  163. Which proposal? I have advanced no proposal at all. That in non side
  164. effect free languages EQ and EQUAL are different predicates and that
  165. values with different addresses/identities may denote different
  166. mathematical entities is not a proposal, it is a fact. I mentioned
  167. functional languages only as the exception, as they are, as a rule, side
  168. effect free.
  169.  
  170. Hathaway> I don't claim that object identity is exclusively
  171. Hathaway> object-oriented, but that object-orientation includes object
  172. Hathaway> identity.
  173.  
  174. This is a very curious claim; you seem to say that the one cannot do OO
  175. programming in pure, side effect free languages. This is rather
  176. astonishing, and will be news for a few people, who have been, in their
  177. innocence, doing research on what they believed to be direct support for
  178. the OO paradigm in pure/side effect free languages for quite a long
  179. time. :-)
  180.  
  181. Hathaway> [ ... identity and value ... ].  Again, the distinction is so
  182. Hathaway> important that it should not be possible to confuse the two,
  183. Hathaway> let alone to consider them synonymous.
  184.  
  185. Who ever did this? As to me I was quite clear that a value/object may
  186. have both an extension and an intension, the only exception being
  187. pure/functional/side effect free languages (and HashCons Lisp) in which
  188. the identity of a value is not visible, only its
  189. contents/"value"/extension representation.
  190.  
  191.  
  192. pcg> I also cannot find any way in which names are more loosely bound to the
  193. pcg> objects they denote in Smalltalk or Lisp rather than in conventional
  194. pcg> (algorithmic?) languages (like Eiffel or C++?).
  195.  
  196. Hathaway> Easy, names in Smalltalk can refer to any object (names are
  197. Hathaway> loosely bound to the objects they denote), names in C++ that
  198. Hathaway> are not references or pointers can only denote one object
  199. Hathaway> (names are tightly bound to the objects they denote).
  200.  
  201. This is a very peculiar definition of loose/tight and use of the term
  202. 'binding'. Besides surely in C++ variables and other denoting entities
  203. can refer to many objects. I think here you are confusing two distinct
  204. concepts: whether a language is pointer based, and whether it is
  205. weakly/latently typed.
  206.  
  207. Smalltalk happens to be pointer based (all objects must be accessed via
  208. a pointer) *and* latently typed (a denoting entity can denote objects of
  209. any type/class/mode); C++ happens not to be pointer based (denoting
  210. entities can denote objects directly) and strongly/statically typed (a
  211. denoting entity can only denote objects of a given type/mode/class).
  212.  
  213. I think that what you wrote is a slip, what you probably meant was (as I
  214. think I have written in another of my multinefarious postings):
  215.  
  216.   Many OO languages are pointer (or "reference") based; in them
  217.   a denoting entity can only denote a pointer to an object. Some
  218.   aren't. Some OO languages also (often those that are pointer based,
  219.   but not necessarily) are weakly/latently/dynamically typed, in that
  220.   the type/mode/class of a value/object accessible thru a named or
  221.   unnamed entity is not known until runtime; some other OO languages
  222.   are strongly/statically typed, in that the type/mode/class of all
  223.   values/objects that can be accessed via an entity is declared at
  224.   compile time. Neither quality is essential for OO languages; indeed
  225.   both qualities apply in their various combination to non OO languages.
  226.