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-Thread: a07f3367d7,c469fdacc2f3302b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!news.mixmin.net!feeder.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Charmed Snark Newsgroups: comp.lang.ada Subject: Re: Dynamic Variant Record Creation Date: Wed, 17 Mar 2010 14:22:11 +0000 (UTC) Organization: The Snarky Insanitorium Message-ID: References: Injection-Date: Wed, 17 Mar 2010 14:22:11 +0000 (UTC) Injection-Info: feeder.eternal-september.org; posting-host="9f8M0iN5t54V+4DF/iqO8g"; logging-data="16094"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5KGLQViS0vIq1Ehc3MDnzucmgf9b3CSI=" 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:iPyE9Nq2lGO2CPAoe5Qa5mx8h90= Xref: g2news2.google.com comp.lang.ada:10597 Date: 2010-03-17T14:22:11+00:00 List-Id: Robert A Duff expounded in news:wcceijk0vze.fsf@shell01.TheWorld.com: > Warren writes: > >> except that the discriminant also be described somehow >> as 3-bits. > > I'm not sure what you mean. If you're saying "I don't know > how to specify the layout for discriminants", then the answer > is "same as other components" -- you just put the usual > "Discrim at ... range 0..2" or whatever. Yep, that was what I was after. So it _is_ possible after all ;-) I'll keep that in my back pocket for now, because I got things working satisfactory now. My cases where I had auxiliary info were not that numerous, so I just created a couple of factory functions employing case statements. Wordy, but it works. The "Georg" solution was good for that "catch all case" where there was no aux info involved. >>> You said you wanted efficiency. Well, this: >>> >>> T : Token_Type := Token_Type'Val(Character'Pos(Ch)); >>> >>> is unlikely to be efficient. The case statement will be better >>> in that regard. >> >> If true, I'd like to know why. I can't see that in the compiled >> code being much other than a move short. If I get time tonight, >> I'll investigate it. > > Ah, I see I misread your code. I thought you were using > 'Image and 'Value. Sorry. > > So you're right -- the above 'Pos and 'Val should be efficient. Yep, it is (from objdump): 6: c6 45 fd 01 movb $0x1,-0x3(%ebp) a: 66 c7 45 fe 01 00 movw $0x1,-0x2(%ebp) > But I don't think it does what you want! The 'Pos of the > Character '!' is not the same as the 'Pos of the Token '!'. > > - Bob Oh yes it does, hee hee. My awk script goes to great lengths to define the Token_Type to align with the characters (it generates the type specification from #defines, sorted and munged from the yacc output y.tab.h). I did alude to this in the first post as a FYI, that it has a for Token_Type use (...) statement to ensure this. Otherwise, you would be quite correct. Thanks to everyone, the problem is now solved and I can move on. The Georg solution was key. Warren