Path: utzoo!attcan!uunet!huxley!glenn From: glenn@bitstream.com (Glenn P. Parker) Newsgroups: comp.std.c++ Subject: Re: casting "const" to "non-const" Message-ID: Date: 1 Aug 90 18:53:26 GMT References: <56159@microsoft.UUCP> <56163@microsoft.UUCP> <1913@ux.acs.umn.edu> Sender: glenn@huxley.UUCP Reply-To: (Glenn Parker) Distribution: comp Organization: Bitstream, Inc. Lines: 25 In-reply-to: hopper@ux.acs.umn.edu's message of 31 Jul 90 02:48:36 GMT In article <1913@ux.acs.umn.edu> hopper@ux.acs.umn.edu (hopper) writes: >In article <56163@microsoft.UUCP> jimad@microsoft.UUCP (Jim ADCOCK) writes: >>Proposed: >> >>That when a parameter [including the hidden "this" parameter] is declared >>"const", or when the object referenced by a parameter is declared "const", >>than it is not legal to modify that which is declared "const" within the >>function. This is to say, the trick of casting to a non-const does not >>work on a parameter declared as "const." Compilers can flag as an error >>these situations. >> > I don't agree with the illegalization of this construct. I think it >is against the spirit of the language to illegalize a cast. Until recently (after C++ invented it), C did not have "const". Therein lies some confusion. I submit that it is absurd to put const in the same category with other type names. Const is not a typename, it is a storage qualifier, like "auto" and "static". You can't typecast from auto to static, and I agree with Jim that you shouldn't be able to cast from const to non-const. -- -------------------------------------------------------------------------- Glenn P. Parker Bitstream, Inc. uunet!huxley!glenn 215 First Street glenn@bitstream.com Cambridge, MA 02142-1270