From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=BAYES_00,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.6 Subject: Re: Is there a way to see if a value is declared as a constant Newsgroups: comp.lang.ada References: From: ldries46 Date: Tue, 14 Sep 2021 08:47:17 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Message-ID: Organization: KPN B.V. Path: eternal-september.org!reader02.eternal-september.org!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe001.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail Injection-Date: Tue, 14 Sep 2021 08:47:17 +0200 Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com" X-Received-Bytes: 2448 Xref: reader02.eternal-september.org comp.lang.ada:62732 List-Id: 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.