comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: "unconstrained subtype in component declaration" vs "discriminant in constraint must appear alone"
Date: Mon, 22 Feb 2021 11:35:07 +0100	[thread overview]
Message-ID: <s101cr$402$1@dont-email.me> (raw)
In-Reply-To: <4086f350-c56b-4eec-91d3-ef685230b011n@googlegroups.com>

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

  parent reply	other threads:[~2021-02-22 10:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22  0:14 "unconstrained subtype in component declaration" vs "discriminant in constraint must appear alone" Mehdi Saada
2021-02-22  6:32 ` J-P. Rosen
2021-02-22 10:14   ` AdaMagica
2021-02-22 10:57     ` Dmitry A. Kazakov
2021-02-22 14:20       ` Mehdi Saada
2021-02-22 15:11         ` J-P. Rosen
2021-02-22 15:55         ` Dmitry A. Kazakov
2021-02-22 16:21           ` Mehdi Saada
2021-02-23 22:06             ` Mehdi Saada
2021-02-24  9:59               ` AdaMagica
2021-02-24 10:04               ` Jeffrey R. Carter
2021-02-24 14:11               ` Simon Wright
2021-02-24 15:57               ` Shark8
2021-02-25  0:13                 ` Mehdi Saada
2021-02-25  8:58                   ` AdaMagica
2021-02-25 10:25                     ` Mehdi Saada
2021-02-25 10:28                     ` Mehdi Saada
2021-02-22 10:35 ` Jeffrey R. Carter [this message]
2021-02-22 14:21   ` Mehdi Saada
2021-02-22 15:02     ` Jeffrey R. Carter
2021-02-22 15:08       ` J-P. Rosen
replies disabled

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