From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: Ichbiah 2022 compiler mode Date: Sat, 21 Dec 2024 13:26:06 -0800 Organization: None to speak of Message-ID: <87frmgwwwh.fsf@nosuchdomain.example.com> References: 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= Xref: news.eternal-september.org comp.lang.ada:66501 List-Id: "Randy Brukardt" 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 */