home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c++
- Path: sparky!uunet!stanford.edu!lucid.com!lucid.com!jss
- From: jss@lucid.com (Jerry Schwarz)
- Subject: Re: Type System
- Message-ID: <1993Jan4.194318.5340@lucid.com>
- Sender: usenet@lucid.com
- Reply-To: jss@lucid.com (Jerry Schwarz)
- Organization: Lucid, Inc.
- References: <1993Jan1.172044.9659@ucc.su.OZ.AU>
- Date: Mon, 4 Jan 93 19:43:18 GMT
- Lines: 38
-
- In article <1993Jan1.172044.9659@ucc.su.OZ.AU>, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- |> Further to a previous post describing modifications to the type
- |> system, I want to try to explain the underlying concept with some
- |> further examples.
- |>
- |> The basic idea is that 'int' and 'T' are object types,
- |> whereas 'int&' or 'const int&' are not object types.
- |> I would say they are 'accessors' to an object of type 'int'.
-
- The semantics of "const" in types is confused because it is also
- unsed with a different meaning in the English descriptions of
- C++. For several years I have been using "immutable" for this
- sense of "const". That adjective hasn't yet caught on but,
- I live in hope.
-
- The way I understand it, when an object is created (constructed)
- it can be "marked" as mutable or immutable. ("Marked" in quotes
- because no runtime marking is implied). This mark cannot be
- changed. The type system is designed so that (barring the
- use of unsafe casts) the following rule is assured.
-
- If an lvalue has non-const type,
- then it refers to a mutable object.
-
- Thus |int&| and |const int&| differ precisely because they
- refer to objects rather than values. The values that these
- objects can hold are the same, but the information we have
- about the setting of the mutability flag is different.
-
- Discussions of "const" in the type system become slippery because
- when talking about values mutability is irrelevant and so "int"
- and "const int" are in some sense the same.
-
- -- Jerry Schwarz
-
-
-
-
-