comp.lang.ada
 help / color / mirror / Atom feed
From: ldries46 <bertus.dries@planet.nl>
Subject: Re: Is there a way to see if a value is declared as a constant
Date: Tue, 14 Sep 2021 08:47:17 +0200	[thread overview]
Message-ID: <nnd$06effbf5$6aa68ebd@010391d1f6c084ba> (raw)
In-Reply-To: <nnd$38993e8c$31c2bc63@28832d745e09e0f7>

Op 13-9-2021 om 19:08 schreef ldries46:
> I have a set of constants that need a different name each for 
> readability. It may not be an array.
> For instance:
> C1 : constant record_item := .....
> C2 : constant record_item := .....
> C3 : constant record_item := .....
> C4 : constant record_item := .....
> C5 : constant record_item := .....
>
> Now in a procedure or a function I have to use one of these constants
> for instance:
>
> function X(C : record_item) return record_Item is
>    RI : record_item;
> begin
>    ..
>    ..
>    RI := C -- This C may only be one of the five constants and not 
> another record_item
>    ..
>    ..
>     return RI;
> end X;
>
> In what way do I test if C is a constant and not another record Item
The reason I want this construction is that it is part of a reusable 
package where one of the functions may only use a constant.
That function is a kind of initiation function that the end user should 
use in his/her end program.
I hoped there would be an attribute that shows if the item is a constant 
and that I want to be be tested. The only simple way I know at this 
moment is adding a boolean to the record that can be tested but that 
means that that boolean may not be reached by the the program  that uses 
the package, so only that boolean should be (limited) private.
The reason that I do not want to use an array is that however the record 
and the functions used on these records are all the same, the physical 
items  are different. Not using an array means that the readability of 
the of the package will be better.

  parent reply	other threads:[~2021-09-14  6:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13 17:08 Is there a way to see if a value is declared as a constant ldries46
2021-09-13 17:27 ` Björn Lundin
2021-09-13 18:48 ` Jeffrey R. Carter
2021-09-13 19:00 ` Dmitry A. Kazakov
2021-09-14  6:47 ` ldries46 [this message]
2021-09-14  6:58   ` Emmanuel Briot
2021-09-14 23:47 ` Shark8
2021-09-18  5:54 ` ldries46
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox