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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,31982f45a4d88565,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-28 15:53:19 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!cyclone.bc.net!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3B12C9E0.5E9B06C8@earthlink.net> From: "Marc A. Criley" Organization: Quadrus Corporation X-Mailer: Mozilla 4.73 [en] (X11; U; Linux 2.2.14-5.0 i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: A Record Interpretation of an Array Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 28 May 2001 22:53:17 GMT NNTP-Posting-Host: 63.178.185.112 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 991090397 63.178.185.112 (Mon, 28 May 2001 15:53:17 PDT) NNTP-Posting-Date: Mon, 28 May 2001 15:53:17 PDT X-Received-Date: Mon, 28 May 2001 15:51:28 PDT (newsmaster1.prod.itd.earthlink.net) Xref: archiver1.google.com comp.lang.ada:7833 Date: 2001-05-28T22:53:17+00:00 List-Id: I'll start with disclaimers :-) I know what I'm going to be asking about is not defined by the language, is non-portable, is implementation defined, etc. I'm just looking to gather some thoughts and opinions here. Consider a plain, simple, fixed-length array of some type--no variants, tagged types, unconstrained anythings, packing pragmas or specifications. Just your plain 'ole basic array. For example, an array (1..5) of Integer. If I wanted to access the contents of this array as a analogous record, I could declare something like: type Record_View is record Field1 : Integer; Field2 : Integer; Field3 : Integer; Field4 : Integer; Field5 : Integer; end record; and do an Unchecked_Conversion between the array type and this record type. Is it reasonable to think this conversion (going either way) would give sensible results? Is there a stronger basis for that answer than a naive "reasonable to think"? What if the array element type was of a record type, whose 'size indicated an odd number of bytes? My experience has been that arrays of such types pad out the elements, and so could one also reasonably expect the analogous record view to equivalently pad out each such field? And last, if the array was multi-dimensional (but still statically constrained), could a record be constructed to correctly overlay that array? For example: type Array_2_X_4 is array (1..2, 1..4) of Some_Type; type Index_2_Elements is record Field1 : Some_Type; Field2 : Some_Type; Field3 : Some_Type; Field4 : Some_Type; end record; type Index_1_Elements is record Field1 : Index_2_Elements; Field2 : Index_2_Elements; end record; (In case someone asks, "What problem are you actually trying to solve here?" The answer is, to manipulate an array via a record-oriented approach. I have a lot of code that does varied and sundry things with record definitions, and by considering an array as a degenerate case of a record (the fields are all of the same, rather than different, types), I can reuse that code to do the exact same kinds of things to arrays that I already do to records.) Marc A. Criley