home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / std / cplus / 1976 < prev    next >
Encoding:
Text File  |  1993-01-05  |  3.8 KB  |  106 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!stanford.edu!lucid.com!lucid.com!jss
  3. From: jss@lucid.com (Jerry Schwarz)
  4. Subject: Re: pointer comparisons
  5. Message-ID: <1993Jan5.222300.29535@lucid.com>
  6. Sender: usenet@lucid.com
  7. Reply-To: jss@lucid.com (Jerry Schwarz)
  8. Organization: Lucid, Inc.
  9. References: <1993Jan1.155241.28217@ucc.su.OZ.AU> <9300300.29980@mulga.cs.mu.OZ.AU> <1993Jan4.200625.5680@lucid.com> <1993Jan5.060332.5262@ucc.su.OZ.AU>
  10. Date: Tue, 5 Jan 93 22:23:00 GMT
  11. Lines: 93
  12.  
  13. In article <1993Jan5.060332.5262@ucc.su.OZ.AU>, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  14. |> In article <1993Jan4.200625.5680@lucid.com> jss@lucid.com (Jerry Schwarz) writes:
  15. |> >In article <9300300.29980@mulga.cs.mu.OZ.AU>, fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
  16. |> >|> 
  17. |> >|> As I noted in a previous article, I don't agree with Scott Turners belief
  18. |> >|> that base class subobjects are objects. To me, these are absurd 
  19. |> >|> consequences, and thus I conclude that the assumption used in deriving them
  20. |> >|> must be flawed.
  21. |> >
  22. |> >Perhaps fjh would specify some of these "absurd consequences".  I
  23. |> >agree with Scott.  Base class subobjects are objects. Anything else 
  24. |> >would be incomprehensible to me.
  25.  
  26. |> 
  27. |>     If an 'object' is something whose attributes are computed
  28. |> from its internal state, then clearly subobjects need not
  29. |> be objects. In the sense an object is 'self contained',
  30. |> an 'instance' of an abstract class cannot be an object.
  31. |> 
  32.  
  33.  
  34. I completely disagree with the premise. Maybe we are using 
  35. "object" in different senses.  An important "attribute" of
  36. an object (defined as a region of storage by both the C 
  37. standard and the ARM) is its relationship to other regions
  38. of storage.
  39.  
  40. To take a simple example
  41.  
  42.     int a[10];
  43.  
  44. It is an important attribute of a[2] that it is the 3rd
  45. subobject of a 10 element array.  
  46.  
  47. struct S { int i ; int j ; } s ;
  48.  
  49. It is an important attribute of s.j that it is the "j" subobject
  50. of s.   
  51.  
  52. If you prefer to use a word other than "subobject" to describe
  53. this relationship, I suppose you can do so.  But however you
  54. describe it, it is an important concept in the semantics of C++.
  55.  
  56. Perhaps you disagree that a[2] or s.j are "objects"?  If so
  57. then I think you should reconsider your terminology.  "object"
  58. is the term used throughout the C standard and ARM for this
  59. concept. 
  60.  
  61. And a "base subobject" bears an analogous relationship to the
  62. containing object(s).  
  63.  
  64. |>     In particular, the semantics of a virtual function
  65. |> in a subobject are not encapsulated in the subobject class
  66. |> definition (especially for pure virtuals :-)
  67. |> 
  68.  
  69. That is correct.  A virtual function call (as I noted in
  70. another item I posted recently) requires taking a base object
  71. and finding the appropriate derived object containing the base
  72. object.  This can't be done based solely on the contents of
  73. the base object.  
  74.  
  75.  
  76. |>     I suspect that only 'complete objects' can really
  77. |> qualify to be genuine, true blue objects. 
  78. |> Which is not to say they shouldn't support object identity.
  79. |> However the current rules do seem to provide object
  80. |> identity --- if at all -- only for complete objects.
  81.  
  82. The data members of a class are also subobjects according to
  83. my understanding.  You're even disallowing that?  
  84.  
  85. |> 
  86. |>     Is the issue not simple: either we waste bytes
  87. |> to obtain object identity for subobjects or we dont.
  88. |> 
  89.  
  90. I can phrase begging questions too. Either we implement the
  91. language correctly or we fudge, save a byte and hope nobody
  92. notices. 
  93.  
  94. Apparently the issue isn't simple.  There is a fundamental
  95. disagreement about the semantics of C++.  If that disagreement
  96. is resolved it will tell us what is a legal implementation.
  97. We can use the consequences for storage layout and sizes as
  98. a criterion for determining the semantics, but it can't be
  99. the sole criterion.
  100.  
  101.    -- Jerry Schwarz
  102.  
  103.  
  104.  
  105.  
  106.