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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ffc9e2fe760c58fd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!i39g2000cwa.googlegroups.com!not-for-mail From: "Steve Whalen" Newsgroups: comp.lang.ada Subject: Re: Records that could be arrays Date: 26 Feb 2006 18:26:43 -0800 Organization: http://groups.google.com Message-ID: <1141007203.046035.264640@i39g2000cwa.googlegroups.com> References: <189zs75645p7g.1usdp56yox0lg$.dlg@40tude.net> <1140924272.052117.106800@u72g2000cwu.googlegroups.com> NNTP-Posting-Host: 70.110.32.96 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1141007209 26091 127.0.0.1 (27 Feb 2006 02:26:49 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 27 Feb 2006 02:26:49 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: i39g2000cwa.googlegroups.com; posting-host=70.110.32.96; posting-account=GBMmzA0AAABrZ0dHOASa3b2Cdf-RliH9 Xref: g2news1.google.com comp.lang.ada:3177 Date: 2006-02-26T18:26:43-08:00 List-Id: Dmitry A. Kazakov wrote: > ... (:-)) Is it C or FORTRAN? I thought nobody uses EQUIVALENCE blocks anymore! > > No, the above is not an implementation of two interfaces by the same type. > It is two overlapped objects of two different types.... I'm not recommending anyone actually use the 'Address overlay, but it is in Ada for a reason. A programmer or designer would have to give me a REAL good reason for doing anything like this in a production system, and even then I'd probably say no: pick record or array. About the only way I'd agree to using such code would be if there were thousands of lines of code that "wanted" to reference a central data structure as an array, and thousands of lines of code that "wanted" to reference the same data as a record, but I don't think I've ever seen this happen in the real world. But... You said it was an Ada language limitation that you couldn't use an array as a record and vice versa. My point is that if it was really important to do this, you have the option to do a risky implementation specific overlay and have the expressive power of both array and record representations. By doing it like in my example, you are documenting the risky behavior and documenting that you have verified that the internal representations of the array and the record are identical at the bit level. And yes, I WANT this kind of trickery to be on a variable by variable basis, not for an entire class or type of data. I don't think I'd want Ada to have a facility to do array and record overlays beyond what exists (in the example I gave), because to me arrays and records are NOT synonymous. I can't think of a single "real world" example where the use of the data and the nature of the data in the application didn't clearly suggest that either it was fundamentally an array or a record. I guess that part of the reason I don't want this feature is because I agree with with Jean-Pierre Rosen's statement that arrays are really for iterative structures, so I don't see much need for this since most of the various types of examples given in this thread are clearly (to me) more safely and properly defined as records. I don't know that I'd want to burden the compiler with trying to ensure that an array and record had bit equal representation clauses either given or implied before allowing such an overlay. If equal internal representation is NOT the case, I'd hate to think of the inefficiency of a program using both "array style" AND "record style" access code with the compiler having to do a lot of "conversion" of representation in order to support the hypothesized "overlay" facility. Ada compilers have enough to keep straight already. Or at least I don't see enough utility in such a feature to justify the added complexity. Of course I may be misunderstanding what array/record overlay facility you have in mind.