From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Problem with indefinite discriminant records in container Date: Tue, 05 Aug 2014 17:05:34 +0100 Organization: A noiseless patient Spider Message-ID: References: <986b5653-f446-4833-9a83-426f45b7c03f@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="c27d95ddf365c2aa748a7ec17a81943e"; logging-data="345"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191OgO3Ed/vkFbEszPeL/1rXprqvmDzBI0=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:mw4eUEoQ6ejvS12/01/iPmO4/Ms= sha1:hk7d+DyULR3mQeUZzVlhcu3Hiuw= Xref: news.eternal-september.org comp.lang.ada:21456 Date: 2014-08-05T17:05:34+01:00 List-Id: john@peppermind.com writes: > How can I store different versions of an indefinite record with > discriminants such as Rt_Class in some array or vector? You should be able to do this. I made a compilable program with mocked-up versions of the omitted types, and it compiles and runs with every version of GNAT I have here. with Ada.Containers.Indefinite_Vectors; procedure John is subtype Methodid is Natural range 0 .. 10; subtype Classid is Natural range 0 .. 10; type Rt_Methods is array (Natural range <>) of Integer; type Rt_Class_Ids is array (Natural range <>) of Integer; type Rt_Class (Method_Table_Size : MethodId; Superclass_Count : ClassId) is record Id : ClassId; Is_Interface : Boolean; Methods : Rt_Methods (1 .. Method_Table_Size); Superclasses : Rt_Class_Ids (1 .. Superclass_Count); Inst_Prop_Count : Natural; Method_Count : Natural; end record; package Class_Vectors is new Ada.Containers.Indefinite_Vectors (Index_Type => ClassId, Element_Type => Rt_Class); use Class_Vectors; type Rt_Classes is new Class_Vectors.Vector with null record; C : Rt_Classes; begin C.Append (Rt_Class'(Method_Table_Size => 1, Superclass_Count => 1, Id => 4, Is_Interface => False, Methods => (1 => 42), Superclasses => (1 => 43), Inst_Prop_Count => 44, Method_Count => 45)); end John; ======================================================================== On a separate front, it seems to me that use Class_Vectors; type Rt_Classes is new Class_Vectors.Vector with null record; are nudging the edge of current GNAT; indexing on the LHS, eg C (0) := ... confused the heck out of the compiler, in differing ways for GNAT GPL 2014 and FSF GCC 4.9.0; something to do with Cursors, I think.