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!.POSTED!not-for-mail From: "Jeffrey R. Carter" 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 23:56:15 +0200 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <9af47760-e731-4cb5-a1a0-d63e31019ce5@googlegroups.com> <877eob1cc6.fsf@nightsong.com> <5c9b9f90-884f-4de7-8663-d39a67949f4f@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 11 May 2018 21:56:15 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="81ed33047450411fd76696670ddbe5f1"; logging-data="16627"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+tcdHcqnvIsFyngObZijmkUODC+GM1O7w=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 In-Reply-To: Content-Language: en-US Cancel-Lock: sha1:QAjw9aAaL4xprWjhdDMasuR81OE= Xref: reader02.eternal-september.org comp.lang.ada:52297 Date: 2018-05-11T23:56:15+02:00 List-Id: On 05/11/2018 11:39 PM, Simon Wright wrote: > > whereas Ada2012 says > > "To convert a record from one representation to another, two record > types with a common ancestor type need to be declared, with no > inherited subprograms." > > which seems to require _three_ types. The example in 13.6 shows this with only 2 types. This is because a type is defined to be its own ancestor (ARM 3.4.1). > But in any case your code doesn't answer my question: what > representation trick could convert between > > type T is record > J : Integer; > end T; > > and > > type BE_T is new T; > for BE_T use record > ????? > end record; I was showing how to use records with representations to get the compiler to do byte swapping for you. There's no way to use them to change the byte order of an integer type directly. -- Jeff Carter "Since I strongly believe that overpopulation is by far the greatest problem in the world, this [Soylent Green] would be my only message movie." Charleton Heston 123