| Deutsch English Français Italiano |
|
<87frmgwwwh.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.ada
Subject: Re: Ichbiah 2022 compiler mode
Date: Sat, 21 Dec 2024 13:26:06 -0800
Organization: None to speak of
Lines: 25
Message-ID: <87frmgwwwh.fsf@nosuchdomain.example.com>
References: <vbc625$at65$1@dont-email.me> <vbdgs7$hedr$1@dont-email.me>
<vk4uee$3lfp0$1@dont-email.me> <vk5tc9$3uoku$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sat, 21 Dec 2024 22:26:09 +0100 (CET)
Injection-Info: dont-email.me; posting-host="2da3a0ffc775f005e8221f105190c671";
logging-data="252352"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7vLTnfufPWLIUj4wE+eKo"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:EGQ3rQCEv8Sv4XI5p/0TwLDg37A=
sha1:FH6O8bLyYJq4vkYLDy3TsAjLYZs=
Bytes: 2014
"Randy Brukardt" <randy@rrsoftware.com> writes:
[...]
> A lot of "variables" in code actually are only written once. In Ada, those
> are better modeled as constants. A constant tells the reader that the value
> doesn't change during the life of the object, which is easier for analysis
> (both human and machine).
[...]
Agreed. But my understanding is that compilers typically do this kind
of analysis anyway, at least when optimization is enabled. For example,
if I write:
N : Integer := 42;
and later refer to the value of N, if the compiler is able to prove to
itself that N is never modified after its initialization, it can replace
a reference to N with the constant 42 (and possibly fold it into other
constant expressions).
Using "constant" for something that isn't going to be modified is good
practice, but I'd say it's for the benefit of the human reader.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */