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,78b2880bc7e78e39 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-16 14:11:06 PST Newsgroups: comp.lang.ada Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!news.iac.net!news-out.cwix.com!newsfeed.cwix.com!newsfeeds.belnet.be!news.belnet.be!news.tele.dk!134.222.94.5!npeer.kpnqwest.net!uunet!ash.uu.net!world!bobduff From: Robert A Duff Subject: Re: RISC Sender: bobduff@world.std.com (Robert A Duff) Message-ID: Date: Fri, 16 Mar 2001 20:30:06 GMT References: <98qumf$5sf$1@nh.pace.co.uk> <98r4g1$7r1$1@nh.pace.co.uk> <3AB22CB2.E8A851A5@averstar.com> <86g0gd5xy2.fsf@acm.org> Organization: The World Public Access UNIX, Brookline, MA X-Newsreader: Gnus v5.3/Emacs 19.34 Xref: supernews.google.com comp.lang.ada:5777 Date: 2001-03-16T20:30:06+00:00 List-Id: Laurent Guerby writes: > Robert A Duff writes: > > There are also a lot of things that rep clauses just can't express. Eg, > > TCP/IP protocols often have data structures defined like "a count byte, > > followed by an array of sub-records" where the count gives the number of > > sub-records, or the number of bytes including (or not including) the > > count byte itself. I would like to have a language that could describe > > that sort of thing at a reasonably high level. > > For the "non including" case, a discriminated record should do the job > in Ada. (OK, it fails for more complicated stuff.) If it's a count of bytes, a discrim record doesn't work. The discrim has to be a count of number of array elements. Also, you can't control where the array goes. And if there's more data after the array, you're in trouble. And some compilers want to put dope fields in the midst of discriminated records. And some compilers allocate some record fields as a pointer to a separately-allocated thing. I actually think Ada takes the wrong approach by letting you (or making you) specify individual bit numbers. I would define a canonical record layout algorithm, and a pragma that requests the canonical layout. (Or two canonical ones -- canonical tightly packed, and canonical not crossing boundaries. Or something like that.) The default should be that the compiler can do what it likes (which presumably is the most efficient thing, subject to keeping compiler complexity within reason). - Bob