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=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d778a4f52acd9d43 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.213.99 with SMTP id nr3mr21737019pbc.2.1325062758186; Wed, 28 Dec 2011 00:59:18 -0800 (PST) Path: lh20ni73130pbb.0!nntp.google.com!news1.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Representation clauses for base-64 encoding Date: Wed, 28 Dec 2011 10:59:15 +0200 Organization: Tidorum Ltd Message-ID: <9m0433FjokU1@mid.individual.net> References: <4ef31672$0$6574$9b4e6d93@newsspool3.arcor-online.net> <9lgls6FticU1@mid.individual.net> Mime-Version: 1.0 X-Trace: individual.net EQWESbjIxZOTrMC4yrzNdwvrIZnhdmCMXd8+//Owpa99j6v3Sk Cancel-Lock: sha1:6YauV6E6riU/GHhJbu+lce6lhgo= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2011-12-28T10:59:15+02:00 List-Id: On 11-12-23 03:42 , Randy Brukardt wrote: > "Niklas Holsti" wrote in message > news:9lgls6FticU1@mid.individual.net... > ... >>> http://www.adacore.com/2008/03/03/gem-27/ >> >> I am surprised and disappointed that there is *no* mention of portability >> problems in that "gem". This is marketing hype for GNAT, not sound >> programming advice. > > There is no portability problem in common use. Depends on what you consider common. The gem even claims that its representation clause makes "Ada" use a biased 7-bit representation for an Integer component with range 100..227. RM chapter 13 only recommends that compilers should support unbiased representations. Which Ada compilers, other than GNAT, can use biased representations? > For instance, Natasha's code > (once the rep. clauses are right) will work on both a big-endian and > little-endian machine without change. Once the representation clauses are corrected, as you say, Natasha's code is the best that can be achieved with chapter 13. But... Natasha's 24-bit-record code works only if the Ada implementation (a) supports chapter 13 as recommended and (b) has a machine scalar of at least 24 bits. We know that some Ada programs run on the 16-bit TI MSP430. Will the 24-bit record code work there? Ok, MSP430 Ada programs are uncommon, but perhaps we want to make them more common. Natasha's code that uses (packed) arrays with Component_Sizes of 6 and 8 bits has more complex portability questions. Of course it also requires support for chapter 13, but I think it needs more than that. It depends on the indexing order and the word size. I don't find anything in chapter 13 or elsewhere in the RM that even requires the indexing order to be the same for different array types, although this is of course very likely to be the case. > The problem occurs when you need to process big-endian data on a > little-endian machine (or vice versa). That is not that common of a need -- The problem occurs when an application inputs or outputs binary data, and the application should be coded in a portable way. I can't believe that this is uncommon. > Most code does not care which bits are which bits in the word -- like this > encoding code -- they just need a consistent representation. That is, it > doesn't matter where bit 0 is, so long as it is the same in every item that > is processed. True for internal data, false for inputs and outputs. If all you want to do is to compress internal data, use pragma Pack, as you suggested. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .