comp.lang.ada
 help / color / mirror / Atom feed
* Rep Specing Variant Records
@ 2009-09-16  1:22 R.B. Love
  2009-09-16  8:19 ` Petter
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: R.B. Love @ 2009-09-16  1:22 UTC (permalink / raw)


I want to understand how a variant record gets rep spec'd.  Let's say I 
have a sample of my record:

type stuff(has_extra:boolean) is
record
    foo: integer;
    bar: integer;
    case has_extra
        when true =>
            blah : float;
        when false =>
            null;
    end case;
end record;

for stuff use
record
    foo at 0 range 0..31;
    bar at 4 range 0..31;
end;

type normal_stuff is new stuff(has_extra=>false);
type good_stuff is new stuff(has_extra=>true);

for good_stuff use
record
    blah at 12 range 0..31;
end record;

for normal_stuff'size use 64;  -- 8 bytes
for good_stuff'size use 96;    -- 12 bytes

First, does the discriminant take up any size in the record?  When I 
tried this with a tagged record, I was told that my placement at 0 
bytes off set classed with the tag.  That's no good.

Second, does the layout of normal_stuff look like I expect it would, 
that is, the same as stuff?

Does the good_stuff record have a complete rep spec?

Thanks for any replies.  I see books covering the rep spec of plain 
records but none seem to cover variant records.







^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-10-10  2:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-16  1:22 Rep Specing Variant Records R.B. Love
2009-09-16  8:19 ` Petter
2009-09-16 10:10 ` Martin
2009-09-16 15:03 ` Adam Beneschan
2009-09-17  2:39   ` Robert Love
2009-09-17  6:57     ` Niklas Holsti
2009-09-17  8:25     ` Martin
2009-09-18  2:28       ` Robert Love
2009-10-10  2:49   ` Randy Brukardt

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