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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: AI12-0218: What is the portable representation clause for processing IETF packets on little-endian machines? Date: Fri, 11 May 2018 17:32:12 -0500 Organization: JSA Research & Innovation Message-ID: References: <9af47760-e731-4cb5-a1a0-d63e31019ce5@googlegroups.com> <877eob1cc6.fsf@nightsong.com> <87po23yusb.fsf@nightsong.com> <87603vyqxc.fsf@nightsong.com> <38ef3024-cc04-43bf-991f-7569eae82f45@googlegroups.com> <87wowbx9e6.fsf@nightsong.com> <3c2c787e-227e-4066-b397-47b23bad3c43@googlegroups.com> Injection-Date: Fri, 11 May 2018 22:32:13 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="31805"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:52302 Date: 2018-05-11T17:32:12-05:00 List-Id: "Dan'l Miller" wrote in message news:3c2c787e-227e-4066-b397-47b23bad3c43@googlegroups.com... ... >> Normally a network programmer wouldn't do that. > >My point is normally a network programmer does exactly what you >describe ..in C.., not Ada, because the engineer years or decades ago >established that C's macros and pointer arithmetic can do what Ada's >record representation clauses cannot, and C's macros and pointer >arithmetic can do what is disdained as uncouth to be performed by > Ada's various accesses: byte manipulations. A pretty silly programmer, if you ask me. An experienced Ada programmer wouldn't use macros and pointer arithmetic because the job can be trivially done with Unchecked_Conversion. (Jeff Carter showed how in another message). I've done so several times in my career, and it works fine and even isn't expensive if implemented correctly. (Unfortunately, GNAT doesn't take advantage of the permissions to share, so it does a lot more operations than necessary - or at least it did a few years back.) Using a representation clause to swap bytes might slightly simplify some code, but it is hugely expensive to (non-GNAT) implementations, prone to misuse, and it is very rarely used, so the cost-benefit ratio is out of whack. Randy.