comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Array of records with default values not propagating to array
Date: Sun, 4 Feb 2018 11:21:36 +0200
Date: 2018-02-04T11:21:36+02:00	[thread overview]
Message-ID: <fdo1l1F2uchU1@mid.individual.net> (raw)
In-Reply-To: <lybmh6nlfl.fsf@pushface.org>

On 18-02-03 17:26 , Simon Wright wrote:

> I find that
>
>    type Card_Info (Trump : Boolean := False) is record
>       Name : Ada.Strings.Unbounded.Unbounded_String;
>       Divinatory_Meaning : Ada.Strings.Unbounded.Unbounded_String;
>       ...
>
>          TDeck (Index) :=
>            (Trump       => True,
>             Trump_Value => Index_1,
>             others      => <>);
>          ...
>
>             TDeck (Index) :=
>               (Trump      => False,
>                Card_Value => Card_Index,
>                Suit_Value => Suit_Index,
>                others     => <>);
>
> compiles OK and seems to run perfectly well. Presumably this is OK
> because the initial value for an otherwise-uninitialized unbounded
> string is the empty string. Or maybe it's GNAT being over-helpful, since
> it seems not to obey ARM 4.3.1(17.1)[1].
>
> [1] http://www.ada-auth.org/standards/rm12_w_tc1/html/RM-4-3-1.html#p17.1

I don't think that ARM paragraph applies to the "others" in this code. 
The paragraph says:

"A record_component_association for a discriminant without a 
default_expression shall have an expression rather than <>"

but the components covered by the "others" in this code are not 
discriminants. The discriminant is the Trump component, and the 
associations for Trump have an expression (True or False), not <>.

(Moreover, the Trump component has a default expression (False), which 
makes ARM 4.3.1(17.1) inapplicable even to "Trump => <>".)

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .


  parent reply	other threads:[~2018-02-04  9:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-03 11:06 Array of records with default values not propagating to array Bojan Bozovic
2018-02-03 14:16 ` Jere
2018-02-03 14:54   ` Bojan Bozovic
2018-02-03 15:26   ` Simon Wright
2018-02-03 16:07     ` Jere
2018-02-04  9:21     ` Niklas Holsti [this message]
2018-02-04  9:32       ` Simon Wright
2018-02-04  2:43 ` Robert Eachus
2018-02-04  4:59 ` Bojan Bozovic
2018-02-04  9:34   ` Simon Wright
2018-02-04 10:07   ` Niklas Holsti
2018-02-04 11:38     ` Bojan Bozovic
2018-02-04 10:19 ` Jeffrey R. Carter
replies disabled

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