From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Run-Time Type Assignment
Date: Wed, 28 Aug 2002 13:41:07 GMT
Date: 2002-08-28T13:41:07+00:00 [thread overview]
Message-ID: <wccsn0zhzik.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: mailman.1030517642.16877.comp.lang.ada@ada.eu.org
"Robert C. Leif" <rleif@rleif.com> 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
next prev parent reply other threads:[~2002-08-28 13:41 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-28 6:53 Run-Time Type Assignment Robert C. Leif
2002-08-28 11:04 ` Robert Dewar
2002-08-28 13:35 ` Robert A Duff
2002-08-28 14:56 ` Larry Kilgallen
2002-08-28 14:31 ` Robert A Duff
2002-08-28 14:59 ` Lutz Donnerhacke
2002-08-28 22:32 ` Robert A Duff
2002-08-29 22:55 ` Dmitry A.Kazakov
2002-08-28 18:03 ` Frank J. Lhota
2002-08-28 18:37 ` Pat Rogers
2002-08-28 22:47 ` Robert A Duff
2002-08-29 13:32 ` Ben Brosgol
2002-08-29 13:52 ` SIMON Claude
2002-08-29 14:30 ` Robert A Duff
2002-08-29 18:27 ` Randy Brukardt
2002-08-29 14:56 ` Robert A Duff
2002-08-30 3:04 ` Ben Brosgol
2002-08-30 22:54 ` Robert A Duff
2002-08-29 15:09 ` Larry Kilgallen
2002-08-29 14:29 ` Marin D. Condic
2002-08-28 13:41 ` Robert A Duff [this message]
2002-08-28 17:15 ` Hyman Rosen
2002-08-28 20:27 ` Björn Lundin
[not found] <002a01c24e5f$9ee347b0$789a0844@robertqgx6k4x9>
2002-08-28 11:33 ` sk
[not found] ` <3D6CB4F5.F4E05D76@myob.com>
2002-08-28 11:37 ` sk
2002-08-28 15:39 ` Robert C. Leif
2002-08-28 18:53 ` Jeffrey Carter
2002-08-28 20:54 ` Robert C. Leif
2002-08-28 22:55 ` Robert A Duff
2002-08-29 3:18 ` Robert C. Leif
[not found] <005101c24ea9$0de9c960$789a0844@robertqgx6k4x9>
2002-08-28 16:06 ` sk
2002-08-28 22:44 ` tmoran
2002-08-29 0:37 ` tmoran
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox