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=-0.5 required=3.0 tests=BAYES_05 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: "unconstrained subtype in component declaration" vs "discriminant in constraint must appear alone" Date: Mon, 22 Feb 2021 11:35:07 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <4086f350-c56b-4eec-91d3-ef685230b011n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 22 Feb 2021 10:35:07 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="3974457536f9c32fab0194618d402ab0"; logging-data="4098"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18a3BZ0If3PiNv8q0Na8l+NVMfZ6hRXKLE=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 Cancel-Lock: sha1:OJeSabi4y4j8oDgVZIChkTIkO+k= In-Reply-To: <4086f350-c56b-4eec-91d3-ef685230b011n@googlegroups.com> Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:61409 List-Id: On 2/22/21 1:14 AM, Mehdi Saada wrote: > > subtype Limit_number is Natural range 0..51; > type CARDS is new Natural range Limit_number'Range; > type Sets_of_Card is array (Limit_number range <>) of Cards; The problem domain is a physical deck of cards. A deck is a sequence where the order is important and each card has a position in the deck. When talking about the position of a card in a deck, we talk about the first card, the second card, ..., the last card. When counting the cards in a deck, we use the numbers 1, 2, ..., N. The only use of zero might be to refer to the number of cards in an empty deck. When modeling this problem domain in software, we should use the same concepts and terminology, so we should use the numbers 1 .. N for the positions of cards in a deck of N cards. When we do this, your problem disappears. Another feature we see in the problem domain is that a deck has a maximum size (the total number of cards), but its current size may change. Your approach doesn't model this very well. You might want to look at PragmARC.Cards.Decks.General https://github.com/jrcarter/PragmARC/blob/Ada-12/pragmarc-cards-decks-general.ads -- Jeff Carter "My dear Mrs. Hemoglobin, when I first saw you, I was so enamored with your beauty I ran to the basket, jumped in, went down to the city, and bought myself a wedding outfit." Never Give a Sucker an Even Break 111