comp.lang.ada
 help / color / mirror / Atom feed
From: Charmed Snark <snark@cogeco.ca>
Subject: Re: Dynamic Variant Record Creation
Date: Wed, 17 Mar 2010 14:22:11 +0000 (UTC)
Date: 2010-03-17T14:22:11+00:00	[thread overview]
Message-ID: <Xns9D3E697B5E46CSnarkCharmedImSure@188.40.43.245> (raw)
In-Reply-To: wcceijk0vze.fsf@shell01.TheWorld.com

Robert A Duff expounded in news:wcceijk0vze.fsf@shell01.TheWorld.com:

> Warren <ve3wwg@gmail.com> 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



  reply	other threads:[~2010-03-17 14:22 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-16 17:11 Dynamic Variant Record Creation Warren
2010-03-16 18:31 ` Georg Bauhaus
2010-03-16 18:57 ` Adam Beneschan
2010-03-16 20:01   ` Warren
2010-03-16 20:09     ` Jeffrey R. Carter
2010-03-16 20:24       ` Warren
2010-03-16 20:40         ` Robert A Duff
2010-03-16 20:44           ` Warren
2010-03-16 20:31     ` Robert A Duff
2010-03-16 20:59       ` Warren
2010-03-16 21:55         ` Jeffrey R. Carter
2010-03-17 14:40           ` Warren
2010-03-18 12:57           ` Warren
2010-03-16 21:58         ` Robert A Duff
2010-03-17 14:22           ` Charmed Snark [this message]
2010-03-17 14:49             ` Robert A Duff
2010-03-17 16:30               ` Warren
2010-03-16 21:15       ` Adam Beneschan
2010-03-16 23:24       ` Adam Beneschan
2010-03-16 20:15   ` Robert A Duff
2010-03-16 21:00     ` Warren
2010-03-16 23:39   ` Randy Brukardt
2010-03-16 23:43     ` Randy Brukardt
2010-03-17  0:15     ` Robert A Duff
2010-03-17 14:28       ` Warren
2010-03-18  0:02       ` Randy Brukardt
2010-03-17  4:20     ` Adam Beneschan
2010-03-18  0:13       ` Randy Brukardt
2010-03-18 13:00         ` Warren
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox