comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Eachus <rieachus@comcast.net>
Subject: Re: Array of records with default values not propagating to array
Date: Sat, 3 Feb 2018 18:43:49 -0800 (PST)
Date: 2018-02-03T18:43:49-08:00	[thread overview]
Message-ID: <c7bab841-24ad-431f-ae17-01a509f1e402@googlegroups.com> (raw)
In-Reply-To: <f326b46d-0ca2-45a8-94b7-bb27b52e54b9@googlegroups.com>

On Saturday, February 3, 2018 at 6:06:52 AM UTC-5, Bojan Bozovic wrote:
> When I defined a record, and set a default value for some of its components, these don't propagate when I make array of these records.
> Thanks for help.

I could explain the rules that result in the need for the others part, but that won't help you move forward.  What I suggest is you first try commenting out the call to Shuffle, and see if you can print out your initial deck.

If so, replace the others with explicit initial values for the two Unbounded_Strings. (Or just temporarily comment out those fields in the declaration and the others.)

If that fixes it, fine.  Send a bug report to Ada_Core and go on with your life and code.

Note that if I were writing this code, I would shuffle a vector, then indirect through the vector to get the card values:
 
type Deck is array (Card_Position) of access Card_Info;

then Initialize assigns values to each.  (Need to change the two TDeck assignments to create new access values.) Now Shuffle swapping pointers instead of several variable length fields.  I think the only change necessary to Shuffle to do this is the declaration of Temporary_Data.

Is this worth doing now?  Only if there really is an GNAT bug and getting rid of the others doesn't fix it.  This is certainly an optimization worth considering after the program is running.

Oh one last detail which you may be leaving until later.  When using tarot decks it is usually important to know if the card is inverted or not.  Again something to add once the rest of it is working.

  parent reply	other threads:[~2018-02-04  2:43 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
2018-02-04  9:32       ` Simon Wright
2018-02-04  2:43 ` Robert Eachus [this message]
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