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

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!decwrl!world!wmm
  3. From: wmm@world.std.com (William M Miller)
  4. Subject: Re: Alternatives to operator.()
  5. Message-ID: <Brqq7D.97w@world.std.com>
  6. Organization: Software Emancipation Technology, Inc.
  7. References: <1992Jul17.213335.19671@microsoft.com> <BrM3LI.CBo@world.std.com> <1992Jul20.235728.29058@microsoft.com>
  8. Date: Tue, 21 Jul 1992 13:16:25 GMT
  9. Lines: 136
  10.  
  11. In article <1992Jul20.235728.29058@microsoft.com>, Jim Adcock writes:
  12. > |That was not my intention in posting this message.  During our earlier
  13. > |exchange a couple of weeks ago, I posted my list of objections to your
  14. > |proposal.  They included, in case you've forgotten:
  15. > In case you've forgotten, I've answered these "objections" repeatedly.
  16.  
  17. Yes, I've read your "answers" (see, I can use the quote key, too --
  18. can we agree to stop casting aspersions on the validity of one
  19. another's mental processes and just deal with the issues
  20. dispassionately?).  The reason I listed my objections here was to
  21. demonstrate that none of them were comparative, not to elicit further
  22. discussion of them.
  23.  
  24. > a) it IS an operator, and always has been.  See for example, K&R 1978
  25. > page 49 lists "->" and "." as BOTH being operators of identical precedence.
  26.  
  27. I've never said that it wasn't an operator -- syntactically it clearly
  28. is.  So is "::".  I contend that "." is more like "::" than like "->".
  29.  
  30. > b) it DOES perform a runtime operation, essentially identical to "->"
  31. > as anyone knows who has looked at the code generated for reference members
  32. > and "." and pointer members and "->"
  33.  
  34. We interpret the data differently here.  The dereferencing code to
  35. which you are referring is the result of the use of a reference in an
  36. expression and not of the appearance of ".".  Let me illustrate in the
  37. context of the following example:
  38.  
  39.     struct X { int i; };
  40.  
  41.     int i;
  42.  
  43.     void f() {
  44.         int i;
  45.         X x;
  46.         X* xp;
  47.         X& xr = x;
  48.  
  49.         // reference expression
  50.  
  51.     }
  52.  
  53. Consider each of the following expressions at the location indicated
  54. by the comment "reference expression":
  55.  
  56.     Expression    Interpretation
  57.     ----------    --------------
  58.  
  59.     i        Fetch the value at the appropriate offset in
  60.             f()'s stack frame
  61.  
  62.     ::i        Fetch the value at the appropriate offset in
  63.             the program's static storage region
  64.  
  65.     x.i        Fetch the value at the appropriate offset in
  66.             the object "x"
  67.  
  68.     (*xp).i        Fetch the value at the appropriate offset in
  69.             the object found by indirecting through the
  70.             value of "xp"
  71.  
  72.     xp->i        Fetch the value at the appropriate offset in
  73.             the object found by indirecting through the
  74.             value of "xp"
  75.  
  76.     xr.i        Fetch the value at the appropriate offset in
  77.             the object to which "xr" refers, i.e., "x"
  78.  
  79. Notice that each of these interpretations begins with the same phrase,
  80. regardless of the presence or absence of "." in the expression.  The
  81. only difference is the context in which the offset is applied.  In two
  82. of the cases, (*xp).i and xp->i, there is an explicit indirection,
  83. which is the overloadable operation.  In the case of "xr.i" there is
  84. deliberate ambiguity as to whether an indirection occurs; a reference
  85. may be, but need not be, implemented by a pointer.
  86.  
  87. The point of this exercise was to demonstrate that, semantically, the
  88. builtin "." only provides qualification for the right hand side --
  89. i.e., an addressing context and a scope in which the right hand side
  90. can be looked up to determine "the appropriate offset" for the
  91. interpretation.  This is exactly what "::" -- or even the absence of
  92. qualification -- does.  I don't imagine this analysis will convince
  93. you, but perhaps you can at least acknowledge that this interpretation
  94. of builtin "." is simple and self-consistent.  To my mind, this
  95. "objection" -- that "." isn't like the overloadable operators -- still
  96. stands.
  97.  
  98. > |      2) Your operator.() proposal continues to require forwarding functions
  99. > |         for member operators and conversion operators in the target class,
  100. > |         even though the requirement of forwarding functions was one of the
  101. > |         most significant criticisms you advanced against the status quo.
  102. > My operator.() proposal DOES NOT require forwarding functions unless
  103. > the implementor of the reference class DESIRES to use forwarding functions.
  104.  
  105. But the same can be said of the current situation -- you only have to
  106. provide forwarding functions for those features of the target class
  107. you desire to use.  The "objection" still stands.
  108.  
  109. > |      3) Your operator.() proposal requires use of circumlocutions to access
  110. > |         members of the smart reference object.
  111. > My proposal DOES NOT require use of circumlocutions to access members of
  112. > the smart reference object.  Circumlocations are POSSIBLE, if the implementor
  113. > of the reference class so desires.
  114.  
  115. This is the same sort of semantic dancing as the previous point; the
  116. fact is that, under your proposal, you must use a circumlocution to
  117. access members of the smart reference object.  The "objection" still
  118. stands.
  119.  
  120. > |My position on
  121. > |your proposal is based on these points, not on a comparison with some
  122. > |semi-mythical "better proposal."
  123. > Then I suggest:
  124. > 1) get your facts right, lest your position be based on errors.
  125.  
  126. Thanks for your concern; my facts are in pretty good shape.
  127.  
  128. > 2) you stop saying your ideas are "better" than my proposal
  129.  
  130. That's not what I said.  What I said was that the two alternatives I
  131. mentioned did not have these three particular disadvantages of your
  132. proposal but that I had not fully explored them.  They may, in fact,
  133. have far worse disadvantages than your proposal (indeed, as I pointed
  134. out in my most recent posting, the reference-conversion idea isn't
  135. even completely free of these disadvantages, since it requires
  136. forwarding functions for conversion functions in the target).  That's
  137. why I posted, to get people to shoot holes in the ideas.  It would
  138. definitely be premature to claim that either is "better" than your
  139. proposal, and I haven't done so.
  140.  
  141. -- William M. Miller, wmm@world.std.com
  142.