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!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: AI12-0218: What is the portable representation clause for processing IETF packets on little-endian machines? Date: Wed, 30 May 2018 09:25:49 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <5f1e44fa-5b78-45a1-a12e-b8089d823540@googlegroups.com> <9ae54be5-0b96-4675-ad95-7a61ecc6fbd0@googlegroups.com> NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:52777 Date: 2018-05-30T09:25:49+02:00 List-Id: On 2018-05-30 08:39 AM, Simon Wright wrote: > "Randy Brukardt" writes: > >> "Simon Wright" wrote in message >> news:ly4litj7qx.fsf@pushface.org... > >>> But it doesn't do byte swapping. >> >> Thank goodness. People use rep. clauses all the time in code that >> permeates an entire program; having very expensive byte swapping code >> easily triggered would give Ada a reputation of being a slug (rather >> than understanding that the code misuses the features). The whole idea >> of portable representation clauses is close to misuse of the feature >> (the entire value is to ensure that compilers for the same target >> intepret the clauses the same way). > > (a) In that case, the LRM should point out this potential problem in red > block caps; or eliminate rep clauses altogether and make us use C-style > shifts and masks (I think that's what Dmitry does anyway). Exactly. But why is it C-style? Differently to C, Ada has a well defined semantics of all operations, shifts included. It is pretty much Ada-style to me, which cannot be said about representation clauses *misused* for this purpose. In my view it is impossible to make representation clauses a machine-independent data definition language. The *only* place for them is machine-dependent low-level code. Anything else is asking for trouble and against Ada principles of keeping code clean. I doubt many people could explain what exactly a complex representation clause does, what it does not do, where and when that happens or not. P.S. It is an old debate about imperative vs. declarative, in which declarative (representation clauses in this case) is always to lose. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de