comp.lang.ada
 help / color / mirror / Atom feed
* Variant record question
@ 2000-01-21  0:00 Mike Silva
  2000-01-21  0:00 ` Robert A Duff
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mike Silva @ 2000-01-21  0:00 UTC (permalink / 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;









^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-01-21  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-21  0:00 Variant record question Mike Silva
2000-01-21  0:00 ` Robert A Duff
2000-01-21  0:00 ` Matthew Heaney
2000-01-21  0:00 ` Ted Dennison

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