comp.lang.ada
 help / color / mirror / Atom feed
From: "Mike Silva" <mjsilva@jps.net>
Subject: Variant record question
Date: 2000/01/21
Date: 2000-01-21T00:00:00+00:00	[thread overview]
Message-ID: <4V0i4.622$dw3.29725@news.wenet.net> (raw)

I've been working on some proof-of-concept code, and I don't understand
something about arrays of variant records.  Specifically, the following code
works with a default discriminant defined for the type T_t, but if I remove
the default discriminant it fails at the declaration of T_array_t.  Why must
I put in a default discriminant when I can then override it in an aggregate
(variable 'A' below)?  Thanks for any clarification.

Mike

package Test is

 type Dis_t is ( D1, D2 );

 type T_t ( D : Dis_t := D1 ) is  -- note default discriminant
   record
      case D is
        when D1 =>
          I : Integer;
        when D2 =>
          F : Float;
      end case;
   end record;

 type T_array_t is array (Integer range <>) of T_t;  -- fails if no default
Dis_t

 A : T_array_t := ( (D => D1, I => 99), (D => D2, F => 99.99) );

end Test;









             reply	other threads:[~2000-01-21  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-21  0:00 Mike Silva [this message]
2000-01-21  0:00 ` Variant record question Robert A Duff
2000-01-21  0:00 ` Matthew Heaney
2000-01-21  0:00 ` Ted Dennison
replies disabled

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