home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / std / cplus / 1967 < prev    next >
Encoding:
Text File  |  1993-01-04  |  1.8 KB  |  51 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: Type System
  5. Message-ID: <1993Jan4.194318.5340@lucid.com>
  6. Sender: usenet@lucid.com
  7. Reply-To: jss@lucid.com (Jerry Schwarz)
  8. Organization: Lucid, Inc.
  9. References:  <1993Jan1.172044.9659@ucc.su.OZ.AU>
  10. Date: Mon, 4 Jan 93 19:43:18 GMT
  11. Lines: 38
  12.  
  13. In article <1993Jan1.172044.9659@ucc.su.OZ.AU>, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  14. |> Further to a previous post describing modifications to the type
  15. |> system, I want to try to explain the underlying concept with some
  16. |> further examples.
  17. |> 
  18. |> The basic idea is that 'int' and 'T' are object types,
  19. |> whereas 'int&' or 'const int&' are not object types.
  20. |> I would say they are 'accessors' to an object of type 'int'.
  21.  
  22. The semantics of "const" in types is confused because it is also
  23. unsed with a different meaning in the English descriptions of
  24. C++.  For several years I have been using "immutable" for this
  25. sense of "const".  That adjective hasn't yet caught on but, 
  26. I live in hope.
  27.  
  28. The way I understand it, when an object is created (constructed)
  29. it can be "marked" as mutable or immutable. ("Marked" in quotes
  30. because no runtime marking is implied).  This mark cannot be
  31. changed.  The type system is designed so that (barring the
  32. use of unsafe casts) the following rule is assured.
  33.  
  34.     If an lvalue has non-const type,
  35.     then it refers to a mutable object.
  36.  
  37. Thus |int&| and |const int&| differ precisely because they
  38. refer to objects rather than values.  The values that these
  39. objects can hold are the same, but the information we have
  40. about the setting of the mutability flag is different.
  41.  
  42. Discussions of "const" in the type system become slippery because
  43. when talking about values mutability is irrelevant and so "int"
  44. and "const int" are in some sense the same.
  45.  
  46.   -- Jerry Schwarz
  47.  
  48.  
  49.  
  50.  
  51.