Groups | Search | Server Info | Login | Register
Groups > comp.lang.c > #388544
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: relearning C: why does an in-place change to a char* segfault? |
| Date | 2024-09-28 13:42 -0700 |
| Organization | None to speak of |
| Message-ID | <875xqfse6g.fsf@nosuchdomain.example.com> (permalink) |
| References | <vd83pq$14kml$1@dont-email.me> <vd9g34$1bmsp$1@dont-email.me> |
Phillip Frabott <nntp@fulltermprivacy.com> writes:
> In reply to "Janis Papanagnou" who wrote the following:
[...]
>> I also think (for various reasons) that "constants" is not a good
>> term. (Personally I like terms like the Algol 68 term, that seems
>> to "operate" on another [more conceptual] abstraction level.)
>>
>> But you'll certainly have to expect a lot of anger if the terminology
>> of some standards documents get changed from one version to another.
>
> The only gripe I would have if we synonymized constants and literals
> is that not every const is initialized with a literal. There have been
> times where I have initialized a const from the value of a variable. I
> don't think that const and literals are the same thing because of
> this.
Though the word "const" is obviously derived from the English word
"constant", in C "const" and "constant" are very different things.
The "const" keyword really means "read-only" (and perhaps would have
been clearer if it had been spelled "readonly").
A "constant" is what some languages call a "literal", and a "constant
expression" is an expression that can be evaluated at compile time.
For example, this:
const int r = rand();
is perfectly valid.
Incidentally, the N3301 draft of the C2Y standard has this change
applied to it:
Syntax
constant:
integer-literal
floating-literal
enumeration-constant
character-literal
predefined-constant
The predefined constants are false, true, and nullptr.
(I find it a bit odd that enumeration and predefined constants are still
called constants, not literals.)
Compare C17:
Syntax
constant:
integer-constant
floating-constant
enumeration-constant
character-constant
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3301.pdf
(open-std.org seems to be down at the moment.)
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
Re: relearning C: why does an in-place change to a char* segfault? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-27 17:33 -0700
Re: relearning C: why does an in-place change to a char* segfault? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-09-27 20:34 -0700
Re: relearning C: why does an in-place change to a char* segfault? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-09-28 07:22 +0200
Re: relearning C: why does an in-place change to a char* segfault? Phillip Frabott <nntp@fulltermprivacy.com> - 2024-09-28 17:57 +0000
Re: relearning C: why does an in-place change to a char* segfault? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-09-28 13:42 -0700
Re: relearning C: why does an in-place change to a char* segfault? Phillip Frabott <nntp@fulltermprivacy.com> - 2024-09-28 22:05 +0000
Re: relearning C: why does an in-place change to a char* segfault? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-09-28 15:17 -0700
csiph-web