From: "Steven L. Zook" <SLZook@Qualstar.com>
To: "Zack Weinberg" <zack@codesourcery.com>,
"Gabriel Dos Reis" <gdr@cs.tamu.edu>
Cc: "Geoffrey Keating" <geoffk@apple.com>,
"Ranjit Mathew" <rmathew@gmail.com>, "GCC" <gcc@gcc.gnu.org>
Subject: RE: Compiling GCC With a C++ Compiler (g++)
Date: Wed, 13 Oct 2004 03:47:00 -0000 [thread overview]
Message-ID: <9E27B4AB55478346B9F7848926E49B7F4F7217@exchange1.qualstar.com> (raw)
Pardon me for intruding here. This may not be applicable to your specifics.
C++ does have a construct for write-once storage; construction. For example,
struct sDerf { sDerf( int WriteOnceValue ) : ReadOnlyValue( WriteOnceValue ) {}
int const ReadOnlyValue;
};
As far as I know, this is the only "supported" method. The rest are tricks that tunnel around the language by using unions, casting, or pointer aliasing.
As far a language deficiency is concerned, I have always thought that some more modifiers than const and volatile would be useful. Especially for embedded programmers like me. The spelling of the following is not important: only the effect matters.
readonly: class members and friends can write but outsiders can only read. This would eliminate having to write accessor functions.
construct: constructor can modify any number of times in initializer list or in body but all others can only read.
interrupt: acts like volatile in non-interrupt service routines and non-volatile in an ISR (where an ISR is marked by some attribute or perhaps by name).
-----Original Message-----
From: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org]On Behalf Of
Zack Weinberg
Sent: Tuesday, October 12, 2004 3:58 PM
To: Gabriel Dos Reis
Cc: Geoffrey Keating; Ranjit Mathew; GCC
Subject: Re: Compiling GCC With a C++ Compiler (g++)
Gabriel Dos Reis <gdr@cs.tamu.edu> writes:
> Geoffrey Keating <geoffk@apple.com> writes:
> | The 'const' is there to indicate that the string should not be changed
> | once the STRING_CST is created;
>
> And how do you create it?
By casting away the const, as is done in build_string. Or by
constructing the data in memory before giving it the type with the
const qualifier.
How else do you propose to enforce write-once semantics on a data
structure that is, in fact, write-once? I am definitely with Geoff
here - this should be allowed (or, to rephrase, if C++ has no
construct which allows what we want to do here, that is a language
deficiency).
zw
next reply other threads:[~2004-10-12 23:23 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-13 3:47 Steven L. Zook [this message]
2004-10-13 7:26 ` Gabriel Dos Reis
-- strict thread matches above, loose matches on Subject: below --
2004-10-11 9:53 Ranjit Mathew
2004-10-12 10:06 ` Ranjit Mathew
2004-10-12 13:17 ` Gabriel Dos Reis
2004-10-12 21:15 ` Geoffrey Keating
2004-10-12 23:00 ` Gabriel Dos Reis
2004-10-12 23:23 ` Zack Weinberg
2004-10-13 2:53 ` Phil Edwards
2004-10-13 6:24 ` Gabriel Dos Reis
2004-10-13 10:57 ` Andreas Schwab
2004-10-13 13:16 ` Gabriel Dos Reis
2004-10-13 13:56 ` Andreas Schwab
2004-10-13 14:22 ` Gabriel Dos Reis
2004-10-13 15:06 ` Andreas Schwab
2004-10-13 15:22 ` Gabriel Dos Reis
2004-10-13 15:33 ` Andreas Schwab
2004-10-13 18:20 ` Gabriel Dos Reis
2004-10-13 19:09 ` Andreas Schwab
2004-10-13 11:47 ` Dave Korn
2004-10-13 12:24 ` Andreas Schwab
2004-10-13 13:29 ` Gabriel Dos Reis
2004-10-13 14:10 ` Andreas Schwab
2004-10-13 14:30 ` Dave Korn
2004-10-13 14:50 ` Dave Korn
2004-10-13 18:25 ` Andreas Schwab
2004-10-13 15:04 ` Joseph S. Myers
2004-10-13 17:01 ` Dave Korn
2004-10-13 21:16 ` Geoffrey Keating
2004-10-14 13:26 ` Dave Korn
2004-10-14 13:32 ` Gabriel Dos Reis
2004-10-14 18:40 ` Andreas Schwab
2004-10-14 18:48 ` Gabriel Dos Reis
2004-10-14 20:33 ` Geoffrey Keating
2004-10-14 20:19 ` Geoffrey Keating
2004-10-15 12:03 ` Kai Henningsen
2004-10-13 14:53 ` Gabriel Dos Reis
2004-10-13 15:46 ` Gabriel Dos Reis
2004-10-13 19:41 ` Matt Austern
2004-10-13 20:29 ` Andreas Schwab
2004-10-13 20:41 ` Matt Austern
2004-10-13 20:58 ` Phil Edwards
2004-10-13 9:23 ` Ranjit Mathew
2004-10-13 13:09 ` Ranjit Mathew
2004-10-13 19:13 ` Richard Henderson
2004-10-13 21:55 ` Gabriel Dos Reis
2004-10-13 13:29 ` Gabriel Dos Reis
2004-10-13 5:49 ` Gabriel Dos Reis
2004-10-13 9:19 ` Zack Weinberg
2004-10-13 13:45 ` Gabriel Dos Reis
2004-10-13 20:39 ` Geoffrey Keating
2004-10-13 21:45 ` Gabriel Dos Reis
2004-10-13 22:15 ` Geoffrey Keating
2004-10-13 22:24 ` Gabriel Dos Reis
2004-10-13 22:53 ` Joseph S. Myers
2004-10-13 23:19 ` Geoffrey Keating
2004-10-14 0:21 ` Gabriel Dos Reis
2004-10-14 6:04 ` Andreas Schwab
2004-10-14 7:10 ` Gabriel Dos Reis
2004-10-14 11:29 ` Andreas Schwab
2004-10-14 13:06 ` Gabriel Dos Reis
2004-10-14 18:37 ` Andreas Schwab
2004-10-15 12:48 ` Kai Henningsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9E27B4AB55478346B9F7848926E49B7F4F7217@exchange1.qualstar.com \
--to=slzook@qualstar.com \
--cc=gcc@gcc.gnu.org \
--cc=gdr@cs.tamu.edu \
--cc=geoffk@apple.com \
--cc=rmathew@gmail.com \
--cc=zack@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).