From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Test for constant (or "in parameter" in procedure)
Date: Thu, 9 Feb 2017 14:09:11 +0100
Date: 2017-02-09T14:09:11+01:00 [thread overview]
Message-ID: <o7hplm$1072$1@gioia.aioe.org> (raw)
In-Reply-To: 24a8808f-dd9e-4fcf-bbe5-226f56a41eb9@googlegroups.com
On 09/02/2017 13:46, reinkor wrote:
> OK, I here try to communicate my intention via this simple example:
>
> i : Constant Integer := 5; -- all OK so far (but someone could
> change this to a variable)
>
> begin
>
> .... some code ...
>
> if "i is not constant (cannot change value)" then
> Some_error_handling;
> end if;
i cannot change its value all its life time. This is regardless how its
initial value was obtained.
> (or alternatively error message/warning at compilation)
Maybe we could help better if you tell us what the original problem is.
If you consider this:
loop
declare
I : constant Integer := Read_From_File;
begin
...
end;
end loop;
It would be meaningless to ask if I changes its value. There are many
I's all unrelated to each other. If you want to relate them, you must
move the declaration of I to the least common scope, e.g. like this:
declare
I : Integer; -- Now it is only one I for each iteration
begin
loop
I := Read_From_File;
...
end loop;
end;
You can immediately see that I is not a constant. And you could not make
it constant.
As it was said, it is either constant (immutable) or not (mutable). Your
very question is meaningless.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2017-02-09 13:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-09 4:38 Test for constant (or "in parameter" in procedure) reinkor
2017-02-09 12:11 ` AdaMagica
2017-02-09 12:46 ` reinkor
2017-02-09 13:09 ` Dmitry A. Kazakov [this message]
2017-02-09 14:10 ` AdaMagica
2017-02-09 15:01 ` reinkor
2017-02-09 16:51 ` G.B.
2017-02-09 16:59 ` reinkor
2017-02-09 17:17 ` Dmitry A. Kazakov
2017-02-09 17:31 ` G.B.
2017-02-09 18:46 ` Niklas Holsti
2017-02-10 7:48 ` reinkor
2017-02-09 18:03 ` Jeffrey R. Carter
2017-03-26 20:57 ` Norman Worth
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox