Sujet : Re: Ichbiah 2022 compiler mode
De : randy (at) *nospam* rrsoftware.com (Randy Brukardt)
Groupes : comp.lang.adaDate : 24. Dec 2024, 02:00:32
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vkd13i$1fk3i$1@dont-email.me>
References : 1 2 3 4 5
User-Agent : Microsoft Outlook Express 6.00.2900.5931
"Jeffrey R.Carter" <
spam.jrcarter.not@spam.acm.org.not> 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