home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / std / cplus / 972 < prev    next >
Encoding:
Text File  |  1992-07-28  |  9.0 KB  |  213 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!microsoft!hexnut!jimad
  3. From: jimad@microsoft.com (Jim Adcock)
  4. Subject: Re: Alternatives to operator.()
  5. Message-ID: <1992Jul27.204820.8400@microsoft.com>
  6. Date: 27 Jul 92 20:48:20 GMT
  7. Organization: Microsoft Corporation
  8. References: <Brqq7D.97w@world.std.com> <1992Jul23.024159.18039@microsoft.com> <BruME9.HGJ@world.std.com>
  9. Lines: 202
  10.  
  11. In article <BruME9.HGJ@world.std.com> wmm@world.std.com (William M Miller) writes:
  12. |I wonder if it ever occurred to you that the explanation for my
  13. |continuing to maintain my objections is that we disagree about the
  14. |validity of your arguments, rather than that I have forgotten them or
  15. |didn't understand them in the first place?
  16.  
  17. I considered such a possibility but I had to reject this hypothesis in
  18. the face of your continued misstatements about my proposal.  If you
  19. understood my proposal, you would not make misstatements about it, but
  20. rather would argue against it using true statements.
  21.  
  22. |expr        addressing context    scope
  23. |----        ------------------    -----
  24. |i        stack frame of f()    f()
  25. |
  26. |::i        program static        file
  27. |        storage
  28. |
  29. |x.i        x            class X
  30. |
  31. |(*xp).i        object to which xp    class X
  32. |        points (indirection)
  33. |
  34. |xp->i        object to which xp    class X
  35. |        points (indirection)
  36. |
  37. |xr.i        object to which xr    class X
  38. |        refers (may not be
  39. |        an indirection,
  40. |        depending on
  41. |        implementation)
  42. |
  43. |In each case, you look up the name "i" in the implied scope, take the
  44. |corresponding offset out of the symbol table, and add it to the base
  45. |address implied by the addressing context.  
  46.  
  47. Your statement is incorrect in both the (*xp) and xp-> cases above,
  48. therefore how can it be an argument against operator.() ?
  49.  
  50. I keep making this point, and you keep ignoring it:
  51.  
  52. The language ALREADY permits operators *, &, and -> to be overloaded, yet
  53. you keep making arguments pretending that these overloadable operators
  54. don't ALREADY exist.  You insist that operator.() must be a simple
  55. binding.  Yet this statement is already false within the language.
  56. If your statement were true, then the following two expressions would
  57. have to be identical:
  58.  
  59.     (*pfoo).doSomething();
  60.  
  61.     pfoo -> doSomething();
  62.  
  63. yet the language ALREADY permits such a statement NOT to be true.
  64. Dot therefore, already DOES NOT represent "just" a simple binding,
  65. because overloadable operators &, *, and -> ALREADY "break" this 
  66. statement.  ON THE CONTRARY, then, we need overloadable operator.()
  67. to ALLOW such relationships to continue to be made, in the face of
  68. ALREADY overloadable operators &, * and ->
  69.  
  70. |Whether you use the
  71. |resulting address in an lvalue or rvalue context is immaterial to the
  72. |process.  The role of "." is simply to indicate that the expression
  73. |preceding the "." is to be used to determine the addressing context
  74. |and scope for the interpretation of the name following.  This is
  75. |exactly analogous to what "::" and the absence of qualification do.
  76.  
  77. Again, the fact that -> and * can be overloaded INDEPENDENTLY 
  78. ALREADY contradicts your statement, since they already allow 
  79. the historical relationship:
  80.  
  81.     (*pfoo).     <==>    pfoo->
  82.  
  83. to be violated.  On the contrary then, "." must represent the DIFFERENCE
  84. in the operation of (*pfoo) and pfoo-> so that the overall relationship
  85. can be maintained.
  86.  
  87. |    x.i;
  88. |
  89. |This isn't detailed enough.  Using your terminology, it should read,
  90. |"reference to the object named 'i' within the object 'x'", which is
  91.  
  92. Wrong.  If this were my terminology, then in the following:
  93.  
  94.     px -> i;
  95.  
  96. would mean "i within the object referred to by px"
  97.  
  98. which is clearly a false statement given that the language ALREADY
  99. allows operator-> to be overloaded.
  100.  
  101. |Just out of curiosity, did you ever program in Bliss?  If I recall
  102. |correctly, it has this idea that every name is really just a pointer.
  103.  
  104. No, on the contrary, I program in C++, which has this idea that every
  105. name is really just a reference.
  106.  
  107. |If the target class has a member operator and you want to use it via
  108. |the smart reference, you MUST provide a forwarding function under your
  109. |proposal.  Neither your operator.() nor the conversion function
  110. |alleviates this necessity.  
  111.  
  112. I have pointed out that there is a tiny fixed set of unary member operators
  113. where ARM requires the LHS to be a member.  ARM pages 333-337 lists these
  114. as I have previously noted.  The pertinent member functions are as follows, 
  115. as I have previously noted:
  116.  
  117. 1) Assignment:        operator=()
  118. 2) Function Call:    operator()()
  119. 3) Substcripting:    operator[]()
  120. 4) Class Member Access:    operator->()
  121.  
  122. That's It.  Since there is such a small fixed set of possible functions, 
  123. this does not represent a "real" argument against operator.(), but rather
  124. represents an argument in choice of implementation syntax.  This small
  125. FIXED set of operators could be implemented using templates, or macros,
  126. for example.  This is a very DIFFERENT situation from forwarding member
  127. functions in general, where the names of the member functions cannot be
  128. predicted in advance, and where the set of functions to be forwarded IS NOT
  129. tiny.
  130.  
  131. Further, as I have previously noted, these set of four functions are exactly
  132. the ones that an implementor of a reference class MIGHT NOT want to have
  133. forwarded!  Thus, NOT having these things forwarded automatically might
  134. argubly be considered a "feature."  IF the smart reference class implementor
  135. CHOOSES to have one or more of these tiny fixed set of member operators
  136. forwarded, that CHOICE is TRIVIAL to implement.
  137.  
  138. BUT, what if the class implementor CHOOSES NOT to forward one of these 
  139. operators?  What if a "smart reference" implementor CHOOSES that operator=()
  140. should mean -- BY DEFAULT -- assign one smart reference to another
  141. [such as references are implemented in just about all other OOPLS]
  142.  
  143.     ref1 = ref2;    // assign ref2 to ref1 NOT assign refed-ob2 to refed-ob1
  144.  
  145. Your position would prohibit such a CHOICE.
  146.  
  147. |If you "CHOOSE" not to provide such
  148. |forwarding functions, the desired operations simply won't be available
  149. |via the smart reference.  I agree that you have reduced the burden of
  150. |writing forwarding functions in your proposal, but you have not
  151. |eliminated it.
  152.  
  153. Wherever there is a CHOICE, there is a burden.  Some committee members
  154. would keep *all* such choices from the programmer -- but only for 
  155. operator.() out of all the operators.  Again, if operators *, & and ->
  156. were not ALREADY in the language, I could see this.  BUT operators *,
  157. & and -> ARE ALREADY in the language.  These committee members special
  158. case arguments against ONLY overloading operator.() out of this set
  159. of operators is silly.  The argument has already been decided.  Overloaded
  160. * & -> ARE in the langauge ALREADY, therefor so should overloadable operator.()
  161.  
  162. |No circumlocution is needed in the smart reference's member functions,
  163. |agreed, but that was not the context I was describing.  If there is a
  164. |"metaoperation" to be performed on the smart reference itself, the
  165. |circumlocation *is* necessary.  Such metaoperations might include
  166. |status queries, cache invalidation, network rerouting, etc.
  167.  
  168. Again, this represents an implementor CHOICE.  No one forces the programmer
  169. to make these choices, and no one forces the programmer to use operator.()
  170. CHOICES available to the implementor REMAIN te CHOICE to forward each 
  171.  
  172. function independently, doing with each as they choose, inventing some
  173. new syntax to represent NOT forwarded, etc:
  174.  
  175.     ref.notForwarded();
  176.     ref->notForwarded()
  177.     local(ref).notForwarded();
  178.     notForwarded(ref);
  179.  
  180. etc, etc.
  181.  
  182. These all represent implementor CHOICES.  If the language is to offer
  183. any convenience to the programmer, someone somewhere has to decide that
  184. that convenience IS.  If that convenience fails to meet the needs of some
  185. programmer in some situation, then the programmer needs to be able to
  186. sidestep the "convenience."  You argue that because a language default
  187. doesn't meet the needs of everybody always, we shouldn't offer it to anybody
  188. ever.  This is a vacuous argument.
  189.  
  190. |I have explored your proposal.  The three disadvantages are still
  191. |there.  Refusing to acknowledge them doesn't make them go away.  There
  192. |is room for discussion about the degree to which they are significant,
  193. |but denial doesn't move that discussion forward very much.
  194.  
  195. I am happy to acknowledge strengths and weaknesses in my proposal.
  196. However, I will continue to try to refute erroneous statements that you
  197. or any other people make against it.  Again, rather then keep making 
  198. vacuous arguments that "my" proposal is "half-empty" why don't *you*
  199. write down *your* counterproposal for how something, anything else would
  200. work that is better.  Because right now, your counter-proposal is not
  201. "half-empty" -- rather it is totally empty, because you have refused to
  202. counter-suggest any CONCRETE counterproposal, such that you, I or the
  203. other guy can COMPARE two CONCRETE proposals, in order to discover
  204. which might be better.  Again, put up or shut up.  Either come up with
  205. something better, or get out of the way.
  206.  
  207. I suggest that if you or some other committee member puts in the work to
  208. TRY to come up with a better counterproposal, you will quickly find out
  209. that my proposal isn't nearly as bad as you would suggest.  But you refuse
  210. to address that possibility, by refusing to do any such CONCRETE work.
  211.  
  212.  
  213.