Article View: comp.std.c++
Article #1455Re: Type System
From: Jerry Schwarz
Date: Mon, 11 Jan 1993 23:34
Date: Mon, 11 Jan 1993 23:34
54 lines
2350 bytes
2350 bytes
In article <1993Jan10.162757.1097@ucc.su.OZ.AU>, maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
jss:
|> >You're right. I knew about that loophole, but forgot about it when
|> >I posted my original item. If anyone has ideas for a clean way
|> >to close this loophole, I'd be interested to hear them.
|>
maxtal:
|> Do we want to close it?
I do.
jss:
|> >
|> >The problem is that the object is only "marked" immutable when the
|> >constructor returns. The constructor itself is supposed to be free
|> >to modify the object in any way it chooses.
maxtal:
|>
|> The problem is that the object is *never* marked const.
|> What is made const is the 'reference' or pointer to the object.
The original item explained that "marking" wasn't actually caried
out a runtime, but the concept is useful in explaining the intentions
of the type system.
To repeat. The desired (by me) property (with slightly more
explicit wording than the original and avoiding the use of "mark's")
is
If an object is constructed const(immutable), then
between the time that the constructor (if any) completes
and the destructor (if any) is called (if ever) the
type system should guarantee that any expression that refers to
this object or a subobject of it will do so via
const(qualified) type.
I use const(immutable) to indicate a property of an object, and
const(qualified) to indicate a property of a type.
This is a desirable property whether or not "const" has any effect
on the primitives, and whether or not the language specifies the
effect of modifying a const(immutable) object.
Anything that permits violation of this property is a "loophole".
The rest of maxtal's discussion concerned the meaning of "const",
which is a different subject altogether.
-- Jerry Schwarz
Technical Details
Message-ID:
<1993Jan11.233427.1323@lucid.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!lucid.com!lucid.com!jssReferences:
<1993Jan4.194318.5340@lucid.com> <C0Iy9o.9x@frumious.uucp> <1993Jan9.001948.28388@lucid.com> <1993Jan10.162757.1097@ucc.su.OZ.AU>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!lucid.com!lucid.com!jss From: jss@lucid.com (Jerry Schwarz) Subject: Re: Type System Message-ID: <1993Jan11.233427.1323@lucid.com> Sender: usenet@lucid.com Reply-To: jss@lucid.com (Jerry Schwarz) Organization: Lucid, Inc. References: <1993Jan4.194318.5340@lucid.com> <C0Iy9o.9x@frumious.uucp> <1993Jan9.001948.28388@lucid.com> <1993Jan10.162757.1097@ucc.su.OZ.AU> Date: Mon, 11 Jan 93 23:34:27 GMT Lines: 54