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

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: pointer comparisons
  5. Message-ID: <1993Jan6.184907.5974@ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  9. References: <1993Jan4.200625.5680@lucid.com> <1993Jan5.060332.5262@ucc.su.OZ.AU> <1993Jan5.222300.29535@lucid.com>
  10. Date: Wed, 6 Jan 1993 18:49:07 GMT
  11. Lines: 136
  12.  
  13. In article <1993Jan5.222300.29535@lucid.com> jss@lucid.com (Jerry Schwarz) writes:
  14. >In article <1993Jan5.060332.5262@ucc.su.OZ.AU>, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  15.  
  16. >|>     If an 'object' is something whose attributes are computed
  17. >|> from its internal state, then clearly subobjects need not
  18. >|> be objects. In the sense an object is 'self contained',
  19. >|> an 'instance' of an abstract class cannot be an object.
  20. >|> 
  21. >
  22. >
  23. >I completely disagree with the premise. 
  24.  
  25.     Fair enough. If you want subobjects to be counted
  26. as objects, you must!
  27.  
  28. >Maybe we are using 
  29. >"object" in different senses.  An important "attribute" of
  30. >an object (defined as a region of storage by both the C 
  31. >standard and the ARM) is its relationship to other regions
  32. >of storage.
  33.  
  34.     Maybe we are using "attribute" in different senses.
  35. For me an attribute is a function returning boolean with
  36. one argument.
  37.  
  38.     A relation returns boolean and has two arguments,
  39. and it is not an attribute: an attribute is an intrinsic
  40. property, needing no reference to the outside world
  41. or other thing for its evaluation.
  42. >
  43. >To take a simple example
  44. >
  45. >    int a[10];
  46. >
  47. >It is an important attribute of a[2] that it is the 3rd
  48. >subobject of a 10 element array.  
  49.  
  50.     It is a relation between a and a[2] at best.
  51. >
  52. >struct S { int i ; int j ; } s ;
  53. >
  54. >It is an important attribute of s.j that it is the "j" subobject
  55. >of s.   
  56.  
  57.     A relation. Not a property of 's.j' which as an object
  58. is merely an 'int'. Yes, as an object that 'int' has an address
  59. distinct from other ints. Two different 'int's may have the same
  60. value, and the same 'int' object may have different values
  61. at different times.
  62.  
  63.     The address of the int object 's.j' is an attribute
  64. of 's.j' as an object. Its relation as an object to 's'
  65. is not an attribute of 's.j'.
  66. >
  67. >Perhaps you disagree that a[2] or s.j are "objects"?  
  68.  
  69.     No, I agree they are objects.
  70.  
  71.     I do not necessarily agree their relationship
  72. to other objects is a property they possess as objects,
  73. however. In fact, I might contend that maintaining
  74. this is a violation of the notion of encapsulation.
  75. An objects relation to some other object is an intrinsic
  76. property of the object if, and only if, it contains
  77. a pointer (or reference) to that other object.
  78.  
  79.     Otherwise it is a property of the system,
  80. not the individual object.
  81.  
  82. >And a "base subobject" bears an analogous relationship to the
  83. >containing object(s).  
  84.  
  85.     Not necessarily: contained objects are self contained.
  86. Base subobjects are not always self contained: they are
  87. never self contained if they have pure virtual members.
  88. >
  89. >|>     I suspect that only 'complete objects' can really
  90. >|> qualify to be genuine, true blue objects. 
  91. >|> Which is not to say they shouldn't support object identity.
  92. >|> However the current rules do seem to provide object
  93. >|> identity --- if at all -- only for complete objects.
  94. >
  95. >The data members of a class are also subobjects according to
  96. >my understanding.  You're even disallowing that?  
  97.  
  98.     No, the ARM is disallowing that if you require
  99. object identity as a property of objects. That identity
  100. being determined by pointer comparisons.
  101.  
  102.     Unless I missed something.
  103.  
  104.     class X {};
  105.     class Y { X x1, x2; }
  106.  
  107. Nothing says &x1 != &x2. Perhaps it should. Perhaps I'm wrong.
  108.  
  109. >|>     Is the issue not simple: either we waste bytes
  110. >|> to obtain object identity for subobjects or we dont.
  111. >|> 
  112. >
  113. >I can phrase begging questions too. Either we implement the
  114. >language correctly or we fudge, save a byte and hope nobody
  115. >notices. 
  116.  
  117.     Why is this a 'begging question'? That the bytes
  118. would be wasted in some cases is beyond dispute.
  119. Whether this is important for other than complete objects
  120. I am not sure.
  121.  
  122. >
  123. >Apparently the issue isn't simple.  There is a fundamental
  124. >disagreement about the semantics of C++.  If that disagreement
  125. >is resolved it will tell us what is a legal implementation.
  126. >We can use the consequences for storage layout and sizes as
  127. >a criterion for determining the semantics, but it can't be
  128. >the sole criterion.
  129. >
  130.     As I said I am not sure which choice to make.
  131. I did not intend to claim *making* the choice would be
  132. easy, only that the alternatives are just TWO, and
  133. both of them are well defined and understood.
  134.  
  135.     Am I wrong in this? Are there other alternatives?
  136.  
  137. [My claim is marginally non-trivial: I am disallowing wasting
  138. bytes in included objects but optimising them away in base
  139. subobjects. That would be a third option. But it seems
  140. to me that that does not give proper object identity
  141. semantics to pointer comparisons, and also wastes bytes.
  142. So it is not a good option.]
  143.  
  144. -- 
  145. ;----------------------------------------------------------------------
  146.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  147.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  148. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  149.