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=0.0 required=3.0 tests=BAYES_40,FORGED_GMAIL_RCVD, FREEMAIL_FROM,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?Q?Bj=c3=b6rn_Lundin?= Newsgroups: comp.lang.ada Subject: Re: Is there a way to see if a value is declared as a constant Date: Mon, 13 Sep 2021 19:27:42 +0200 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 13 Sep 2021 17:27:42 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="b17da7d541f611871e25504600636075"; logging-data="19941"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+M/eMHHke+wQkIVFdzQdsx" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 Cancel-Lock: sha1:W68j552jjNyUWbw5Ln4pOFSNF68= In-Reply-To: Content-Language: sv Xref: reader02.eternal-september.org comp.lang.ada:62722 List-Id: Den 2021-09-13 kl. 19:08, skrev 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 := ..... Two approaches - but both uses arrays. You don't say why (more that readability) you don't want array. If it is because integer idexing you can skip that and put the values in an array, using a readable index type eg (for placing bets at Betfair - football/soccer type Bet_Market_Type is (Match_Odds, Correct_Score, Half_Time_Score, Hat_Tricked_Scored, Penalty_Taken, Sending_Off); Market : array (Bet_Market_Type'range) of record_item := (...); use as Market(Correct_Score) := ... or put the values in an array. Let constants rename item in array use constants in code check RI in array > > 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 -- Björn