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,ac2397ce800de518 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-09 10:59:02 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!212.74.64.35!colt.net!dispose.news.demon.net!news.demon.co.uk!demon!pogner.demon.co.uk!zap!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: adasockets and adatypes Date: 08 Sep 2001 06:51:04 +0100 Organization: CodeFella Message-ID: References: <20010904115244.24236db3.tonygair@blueyonder.co.uk> <9n2lpb$c7b$1@nh.pace.co.uk> <3B98C898.99D7A1F6@eraseme.systems.saab.se> NNTP-Posting-Host: localhost X-NNTP-Posting-Host: pogner.demon.co.uk:158.152.70.98 X-Trace: news.demon.co.uk 1000058325 nnrp-07:9005 NO-IDENT pogner.demon.co.uk:158.152.70.98 X-Complaints-To: abuse@demon.net NNTP-Posting-Date: 8 Sep 2001 05:51:04 GMT X-Newsreader: Gnus v5.7/Emacs 20.7 Xref: archiver1.google.com comp.lang.ada:12950 Date: 2001-09-08T05:51:04+00:00 List-Id: Peter Dulimov writes: > Also, what about the efficiency consideration? The compiler > generally chooses the best representation that it can to get > alignment right for complicated data types, and if you go specifying > every bit's position, you are likely to introduce more fix-up > delays. When I have done this (specifying bit patterns for socket > comms with C programs etc), I have had a type defined for "on the > wire" where the representation is specified, and another equivalent > type for internal usage where I let the compiler choose the > representation. The conversion from one type to another is the last > thing that happens {before hitting | after leaving} the wire. Yes. One Ada possibility here is to specify a type without representation clauses and then create a wire format subtype with representation clauses (in a local declarative part). You can make the choice of big- or little-endian depending on the value of System.Default_Bit_Order[1], which with any luck will be optimised at compile time so only one branch is compiled. [1] Purists would argue that this isn't the same as byte order, though it always has been for me.