From: crispen@eight-ball.boeing.com (Bob Crispen)
Subject: Re: Data Overlays
Date: Mon, 23 Aug 93 09:17:54 CDT [thread overview]
Message-ID: <9308231417.AA20947@eight-ball.boeing.com> (raw)
>From: cis.ohio-state.edu!magnus.acs.ohio-state.edu!csn!news.den.mmc.com!iplmai
l!jcrigler@ucbvax.Berkeley.EDU (Jim Crigler) asks:
[and when are we going to get the AJPO host not to put the verbose Bitnet
string on here?]
>What about a variant record? Language Lawyer question (my LRM is at
>home): are rep. specs allowed on variant records? If so (and if you
>have a single tag at any level that determines what the message is at
>that level), use an address clause to store the data on the Byte_Array,
>then use the variant to figure out what you've got.
Alas, this works only when the initial field is the discriminant for the
record (though one could have a fill-in-the-blanks discriminant field,
but my dim recollection is that coping with this is way uglier than
Unchecked_Conversion). Yes, you absolutely can have rep specs on
record types with discriminants. The only exception is that if you
have an unconstrained array in the record, you probably can't do what
you want. For example:
package Bar is
type An_Index is range 0..5;
type An_Array is array (An_Index range <>) of Integer;
type A_Big_Array is array (An_Index) of Integer;
type A_Small_Array is array (An_Index range 0..1) of Integer;
type Long_Boolean is (False, True);
for Long_Boolean'size use 32;
type Bad_Record (Size : An_Index) is
record
The_Array : An_Array (0..Size);
end record;
type Good_Record (Big : Long_Boolean) is
record
case Big is
when True =>
The_Array : A_Big_Array;
when False =>
The_Overlay : A_Small_Array;
end case;
end record;
for Bad_Record use
record
Size at 0 range 0..31;
The_Array at 4 range 0..(6 * 32)-1;
------^A ##
#
--### A:error: RM 13.4(7): component subtype must be static
end record;
for Bad_Record'size use (7 * 32) - 1;
-------^A ##
#
--### A:error: RM 13.2(6): type and its subcomponents must have static constrai
nts
for Good_Record use
record
Big at 0 range 0..31;
The_Array at 4 range 0..(6 * 32)-1;
The_Overlay at 4 range 0..(2 * 32)-1;
end record;
for Good_Record'size use (7 * 32) - 1;
end Bar;
With respect to messages, the least ugly way I've found is, just as
Bill Gilbert says, to use Unchecked_Conversion to do overlays into byte
arrays.
+-------------------------------+--------------------------------------+
| Bob Crispen | Who will babysit the babysitters? |
| crispen@foxy.boeing.com +--------------------------------------+
| (205) 461-3296 |Opinions expressed here are mine alone|
+-------------------------------+--------------------------------------+
next reply other threads:[~1993-08-23 14:17 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-08-23 14:17 Bob Crispen [this message]
-- strict thread matches above, loose matches on Subject: below --
1993-09-01 14:36 Data Overlays David Emery
1993-09-01 4:23 Jim Lonjers
1993-08-31 20:36 dog.ee.lbl.gov!agate!howland.reston.ans.net!math.ohio-state.edu!magnus.ac
1993-08-31 3:51 Jim Lonjers
1993-08-23 14:11 Alex Blakemore
1993-08-19 13:16 cs.utexas.edu!mars.tsd.arlut.utexas.edu!gardner
1993-08-19 2:18 portal!cup.portal.com!R_Tim_Coslet
1993-08-18 16:40 cis.ohio-state.edu!magnus.acs.ohio-state.edu!csn!news.den.mmc.com!iplmail
1993-08-18 16:27 Charles H. Sampson
1993-08-18 16:04 Charles H. Sampson
1993-08-18 12:55 cis.ohio-state.edu!magnus.acs.ohio-state.edu!csn!news.den.mmc.com!iplmail
1993-08-18 12:50 cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!europa.eng.gtefsd.com!fs7.ece.cmu.edu!news.sei.cmu.edu!firth
1993-08-18 2:11 cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!do
1993-08-18 1:53 cis.ohio-state.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.
1993-08-18 0:39 cis.ohio-state.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!cs.utexa
1993-08-17 15:16 Charles H. Sampson
1993-08-13 17:57 cgl!sgiblab!darwin.sura.net!mlb.semi.harris.com!x102a!scook
1993-08-13 12:48 Bob Gilbert
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox