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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,330ec86e1824a689 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-28 06:41:56 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!uunet!sea.uu.net!ash.uu.net!world!news From: Robert A Duff Subject: Re: Run-Time Type Assignment Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Wed, 28 Aug 2002 13:41:07 GMT References: NNTP-Posting-Host: shell01.theworld.com Organization: The World Public Access UNIX, Brookline, MA X-Newsreader: Gnus v5.7/Emacs 20.7 Xref: archiver1.google.com comp.lang.ada:28493 Date: 2002-08-28T13:41:07+00:00 List-Id: "Robert C. Leif" writes: > --Variant Record Approach > --Does not work > type Parameter_Rec_Psuedo_Tagged_Type (Num_Parameters : > Num_Parameters_Type) is --range 1..2 > record > case Num_Parameters is > when 1 => > Parameter_1: Parameter_1_Type; > when 2 => > Parameter_1: Parameter_1_Type; > --Parameter_1 conflicts with declaration 2 lines above. So change the name. Or combine into one field outside the variant part, as suggested in another note. Same-named record fields are illegal in Pascal, too, by the way. > -- tagged record > package Array_Of_Records_Class_Pkg is new Array_Of_Records_G_Pkg( > Length => Num_Of_Records, > Record_Type => Record_Type'Class); > --Bombs because "Actual for "Record_Type" must be a definitive subtype" > --How can I make this dispatch based the Num_Parameters? You don't show the generic, so I can't tell what you're trying to do, but Record_Type has to have (<>) discriminants to allow an indefinite actual. (Roughly speaking, "indefinite" means that different objects of the subtype will have different sizes -- which is true of T'Class.) If your goal is to have an array of different-sized components, that's not directly allowed in Ada. You need some form of indirection, or some such thing. If you change the variant record above to have a defaulted discriminant, then you can create an array of them, but they will be allocated the max size in most compilers. - Bob