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,LOTS_OF_MONEY 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-17 12:18:36 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.direct.ca!look.ca!news1.tor.metronet.ca!nnrp1.tor.metronet.ca!not-for-mail Message-ID: <3B7D6E0B.19366C2A@home.com> From: "Warren W. Gay VE3WWG" X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Variable sizes for record fields References: <9l7qon$d78$1@nntp9.atl.mindspring.net> <8eI27ybFqL0Y@eisner.encompasserve.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Fri, 17 Aug 2001 19:18:36 GMT NNTP-Posting-Host: 198.96.47.195 NNTP-Posting-Date: Fri, 17 Aug 2001 13:18:36 MDT Organization: MetroNet Communications Group Inc. Xref: archiver1.google.com comp.lang.ada:12070 Date: 2001-08-17T19:18:36+00:00 List-Id: Larry Kilgallen wrote: > In article , David Brown writes: > > 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. > > An Ada record type always has a fixed number of discriminants (often zero). Additionally, the discriminants must be discrete types. > > 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. > > That is just the point. Ada requires that the discriminants of the record > can be recognized at run time. There is no way to do that without taking > up space. Another hint : For records that have arrays sized by discriminant(s), it is best to declare those arrays starting from 1. Otherwise you'll have sizing difficulties, because you won't be able to use an expression within the array range to compute the last subscript, within the range. -- Warren W. Gay VE3WWG http://members.home.net/ve3wwg