comp.lang.ada
 help / color / mirror / Atom feed
From: AdaMagica <christ-usch.grein@t-online.de>
Subject: Re: "unconstrained subtype in component declaration" vs "discriminant in constraint must appear alone"
Date: Thu, 25 Feb 2021 00:58:45 -0800 (PST)	[thread overview]
Message-ID: <d9b513a2-d6eb-435f-ad42-25d1610d4f5an@googlegroups.com> (raw)
In-Reply-To: <10e39f4a-9253-4faf-93af-b57ccad92526n@googlegroups.com>

0012...@gmail.com schrieb am Donnerstag, 25. Februar 2021 um 01:13:32 UTC+1:
> But I'm assigning a record aggregate to a mutable type object (so with a default disciminant). 
> So why does it matter if the component's subtype is constrained (here by the discriminant, but whatever) ? 
> It's the very point of mutable objects, to cope with these assignments... or What am I missing ? 
> That's the last issue remaining.

First a word to your attitude.

You ask us a favour to look at your code. That's OK and you're welcome.
But: You ask us to do some work for you. Then may we not expect that you do your work before?

What is your work?

Provide a complete compilable reproducer.
Write it in a consitent and readable style.

Is this expectation on our side really too much?

> type Sets_of_Card is array (Nombre_cartes range <>) of Cards;
> type CARDS_SETS (Nb: Nombre_cartes := 0) is record
> Set: Sets_of_Card (1..Nb) := INITIALIZATION (Nb);
> end record;

> PACK := (pack.nb-1, Pack.Set(pack.set'First..Pack.Nb-1));

This line by itself is not the problem IF Pack really is mutable.

declare
  Pack: Cards_Set := ...;  -- mutable object (no discriminant given in declaration)
begin
  PACK := (pack.nb-1, Pack.Set(pack.set'First..Pack.Nb-1));  -- this is OK, no Constraint_Error
end;

declare
  Pack: Cards_Set (52) := ...;  -- immutalbe object (discriminant given in declaration)
begin
  PACK := (pack.nb-1, Pack.Set(pack.set'First..Pack.Nb-1));  -- Constraint_Error (discriminant check)
end;

  reply	other threads:[~2021-02-25  8:58 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 [this message]
2021-02-25 10:25                     ` Mehdi Saada
2021-02-25 10:28                     ` Mehdi Saada
2021-02-22 10:35 ` Jeffrey R. Carter
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