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,13703514e3723cbe X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-16 23:34:00 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed2.news.rcn.net!rcn!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Sender: David Brown From: David Brown Subject: Re: Variable sizes for record fields Newsgroups: comp.lang.ada References: <9l7qon$d78$1@nntp9.atl.mindspring.net> User-Agent: tin/1.5.8-20010221 ("Blue Water") (UNIX) (Linux/2.4.4-xfs (i686)) Message-ID: Date: Fri, 17 Aug 2001 06:34:21 GMT NNTP-Posting-Host: 64.133.74.64 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 998030061 64.133.74.64 (Thu, 16 Aug 2001 23:34:21 PDT) NNTP-Posting-Date: Thu, 16 Aug 2001 23:34:21 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net X-Received-Date: Thu, 16 Aug 2001 23:31:08 PDT (newsmaster1.prod.itd.earthlink.net) Xref: archiver1.google.com comp.lang.ada:12033 Date: 2001-08-17T06:34:21+00:00 List-Id: Larry Kilgallen wrote: >> I have recently encountered a concrete example of the need for something >> like this. The application is storing variable sized data fields in fixed >> length records (say disk sectors). The block is defined as a large string. >> The beginning of the block contains lengths for each of the variable sized >> fields. The data items start at the end of the record and work their way >> backward. > > This sounds to me like the beginning of the record definition is the > discriminant values and the end of the record is the text fields. > The one trick, to achieve a fixed size, is to have an extra discriminant > to define the size of the "middle". This is based on my experience with > Ada83. Perhaps Ada95 lets you do more "math" with discriminant values > to avoid the need for an extra discriminant. To make this work, I would need several things. First of all, my discriminants would have to be an array of values whose size is based on another discriminant. Second, I need to represent things (like the size of the middle) without taking up any space. They need to be computed and that's it. The sizes of each of the other text strings needs to be based on the array of discriminant sizes. Third, I need to be able to change the structure in-place. It is complicated code, and I don't think that the compiler would understand all of the cases involved, even if you could arbitrarily assign to discriminants like this. I wasn't even able to make a simple record containing a discriminant and a string of that length and come up with a way to make the particular discriminant a constant and not take up any storage. Dave Brown