From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Ichbiah 2022 compiler mode Date: Mon, 23 Dec 2024 19:00:32 -0600 Organization: A noiseless patient Spider Message-ID: References: Injection-Date: Tue, 24 Dec 2024 02:00:35 +0100 (CET) Injection-Info: dont-email.me; posting-host="7679ac0d27a6a387fcac4223d25801d0"; logging-data="1560690"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18TZsnXzaUnPi5NtL1iUReptoQYbLOnQfk=" Cancel-Lock: sha1:s4/6rd5oexwnS2hiMi6WJ3qzvoM= X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MSMail-Priority: Normal X-RFC2646: Format=Flowed; Response X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: news.eternal-september.org comp.lang.ada:66506 List-Id: "Jeffrey R.Carter" wrote in message news:vk631h$3vfb4$1@dont-email.me... ... > I put a lot of effort into making sure that all constants are so declared, > because I have the rule that (with certain exceptions) no non-local > variables may be referenced from subprograms, but constants may be > referenced from anywhere. Precisely. The idea is to encourage use of constants by eliminating the unnatural advantage to writing uninitialized variables. If everything is equally easy/hard to write, then one is more likely to make the best choice for the program. > However, I sometimes have constants that cannot be initialized with a > single expression, resulting in > > C : T; -- Constant after initialization > > Once C has been initialized, I treat it as a constant. Would your approach > allow the compiler to know that C is really a constant? Not with the approach I was envisioning. Of course, Ada 2022 and beyond already make it possible to initialize a lot more objects (especially with the introduction of container aggregates), so hopefully it will be less necessary to write things like your example. Randy. > -- > Jeff Carter > "Anyone who cannot cope with mathematics > is not fully human." > The Notebooks of Lazarus Long > 214