From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: "unconstrained subtype in component declaration" vs "discriminant in constraint must appear alone" Date: Mon, 22 Feb 2021 16:55:18 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <4086f350-c56b-4eec-91d3-ef685230b011n@googlegroups.com> <67ea71d9-489a-4802-9cf0-d955f6ecce62n@googlegroups.com> <0e88c615-6a53-4392-b83d-581c59473c88n@googlegroups.com> NNTP-Posting-Host: 5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:61417 List-Id: On 2021-02-22 15:20, Mehdi Saada wrote: > I just intend to initialize the value once and done. It is a default value, not a dynamic predicate. There are three categories of "once": 1. Once per compilation, static 2. Once per object instantiation, subtype/dynamic constraint 3. Once per object update ------ and any time any place, variable. As J-P said, you can have whatever expressions in #1, just remove discriminants. In other cases you can add more discriminants and a constructing function. E.g. replace type T (L : Positive) is A : S (0..L - 1); end record; with type T (<>) is private; function Create (L : Positive) return T; private type T (L : Positive; Upper : Natural) is A : S (0..Upper); end record; function Create (L : Natural) return T is begin return Result : T (L, L - 1) do ... -- Some initialization end return; end Create; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de