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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c469fdacc2f3302b X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!newsfeed.straub-nv.de!feeder.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Warren Newsgroups: comp.lang.ada Subject: Re: Dynamic Variant Record Creation Date: Thu, 18 Mar 2010 12:57:30 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: Injection-Date: Thu, 18 Mar 2010 12:57:30 +0000 (UTC) Injection-Info: news.motzarella.org; posting-host="9f8M0iN5t54V+4DF/iqO8g"; logging-data="10221"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19gv45TT5cxmpg3drIs+FKCtpnOA7vHRO0=" User-Agent: Xnews/5.04.25 X-Face: &6@]C2>ZS=NM|HE-^zWuryN#Z/2_.s9E|G&~DRi|sav9{E}XQJb*\_>=a5"q]\%A;5}LKP][1mA{gZ,Q!j Cancel-Lock: sha1:U6Rrw1n7CUHh82iPfWkRiIdORNA= Xref: g2news2.google.com comp.lang.ada:10618 Date: 2010-03-18T12:57:30+00:00 List-Id: Jeffrey R. Carter expounded in news:hnov3m$t4o$1@tornado.tornevall.net: > Warren wrote: >> >> The other way for me to solve this is simply provide >> a discrimanant that only identifies the few variants. But >> to keep to 32-bits, I'd have to find a way to specify the >> discriminant as 3-bits, which I don't think is possible. > > Looking at what you have, it looks like a design problem to me. You > have a whole bunch of enumeration values, but you don't have a bunch > of variants. I'd probably have an enumeration type with 3 values that > serves as the discriminant. Then have 3 enumeration types, one for > each variant, that gives the specific information that you're now > trying to use for the discriminant as well. I looked at this closely last night and ended up agreeing with you (design problem). So I changed it along the lines that you suggested: type Token_Type(Aux : Aux_Kind := No_Aux) is record Token : Token_Kind := No_Token; case Aux is when SID_Aux => SID : String_ID; when FID_Aux => FID : Func_ID; when No_Aux => null; end case; end record; I was also able to get the representation I wanted (yeah): for Token_Type use record Aux at 0 range 0..2; Token at 0 range 3..15; SID at 0 range 16..31; FID at 0 range 16..31; end record; This design allows me to flexible in the auxiliary information provided. For example, each "token line" ends with a linefeed token (LEX_LF). However, each statement has an optional "inline" comment like: 01000 LET OPEN_FLAG = FALSE $ Mark file as not-opened. Using the discriminant Aux allowed me to use a SID (Aux = SID_Aux) or not ( Aux = No_Aux ) as required: T := ( Aux => SID_Aux, Token => LEX_LF, SID => ID ); or T := ( Aux = No_Aux, Token => LEX_LF ); As you pointed out, when designed this way, I always know the static representation required, even though the Token member may be variable. I knew that we'd eventually converge on a solution. Thanks everyone. Warren