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

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!spool.mu.edu!wupost!zaphod.mps.ohio-state.edu!uunet.ca!frumious!pat
  3. From: pat@frumious.uucp (Patrick Smith)
  4. Subject: Re: Type System
  5. Message-ID: <C0Iy9o.9x@frumious.uucp>
  6. Date: Fri, 8 Jan 1993 07:32:11 GMT
  7. Reply-To: uunet.ca!frumious!pat
  8. References: <1993Jan1.172044.9659@ucc.su.OZ.AU> <1993Jan4.194318.5340@lucid.com>
  9. Organization: None
  10. Lines: 26
  11.  
  12. jss@lucid.com (Jerry Schwarz) writes:
  13. |The way I understand it, when an object is created (constructed)
  14. |it can be "marked" as mutable or immutable. ("Marked" in quotes
  15. |because no runtime marking is implied).  This mark cannot be
  16. |changed.  The type system is designed so that (barring the
  17. |use of unsafe casts) the following rule is assured.
  18. |
  19. |    If an lvalue has non-const type,
  20. |    then it refers to a mutable object.
  21.  
  22. There is another loophole. :-(
  23. But it's (I hope) an unusual type of situation. :-)
  24.  
  25.    struct A { A(); /*...*/ };
  26.    A* pa;
  27.    A::A { pa = this; }
  28.  
  29.    void f() {
  30.       const A a;
  31.       // Now pa has non-const type but points to an immutable object.
  32.    }
  33.  
  34. -- 
  35. Patrick Smith
  36. uunet.ca!frumious!pat
  37. pat%frumious.uucp@uunet.ca
  38.