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-Thread: 103376,2a0aa2b1c348fd6a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!atl-c02.usenetserver.com!c03.atl99!news.usenetserver.com!news02.tsnz.net!newsfeed01.tsnz.net!ken-transit.news.telstra.net!lon-in.news.telstra.net!news.telstra.net!news-server.bigpond.net.au!53ab2750!not-for-mail From: Dale Stanbrough Newsgroups: comp.lang.ada Subject: Re: shifting bits References: User-Agent: MT-NewsWatcher/3.4 (PPC Mac OS X) Message-ID: Date: Mon, 30 Aug 2004 11:37:33 GMT NNTP-Posting-Host: 138.217.18.112 X-Complaints-To: abuse@bigpond.net.au X-Trace: news-server.bigpond.net.au 1093865853 138.217.18.112 (Mon, 30 Aug 2004 21:37:33 EST) NNTP-Posting-Date: Mon, 30 Aug 2004 21:37:33 EST Organization: BigPond Internet Services Xref: g2news1.google.com comp.lang.ada:3158 Date: 2004-08-30T11:37:33+00:00 List-Id: In article , Ole-Hjalmar Kristensen wrote: > > Have you considered just using a record and specifying which bits > should be allocated to the different fields instead? This would save > you the trouble of doing the packing/unpacking yourself.... Another useful trick is to declare a standard record type... type x is record field1 : sometype; field2 : anothertype; end record; then create a derived type and give it a representation clause. type y is new x; -- apply rep clause for type y. You can then read values into type y. Doing an assignment to an object of type x unpacks the item automatically, and allows for fast access to the components based on the natural alignments that the compiler would choose. E.g. xx : x; yy : y; read (yy); xx := (X) yy; -- unpacks Going the other way also works. Dale -- dstanbro@spam.o.matic.bigpond.net.au