| Deutsch English Français Italiano |
|
<875xqfse6g.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
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: Sat, 28 Sep 2024 13:42:31 -0700
Organization: None to speak of
Lines: 63
Message-ID: <875xqfse6g.fsf@nosuchdomain.example.com>
References: <vd83pq$14kml$1@dont-email.me> <vd9g34$1bmsp$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sat, 28 Sep 2024 22:42:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c8c9fc6402c712ad7f0cce5d4ec18037";
logging-data="1474993"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Rs/NnLhutB+0F+FtRfFAN"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:A2ZloR7VEd9Arqd96nlPHddtucU=
sha1:PLSTEX0WL6++aPxIPSAVG3+0H7o=
Bytes: 3072
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 */