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-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.122.199 with SMTP id lu7mr272412pbb.1.1325018945673; Tue, 27 Dec 2011 12:49:05 -0800 (PST) Path: lh20ni71255pbb.0!nntp.google.com!news1.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Representation clauses for base-64 encoding Date: Tue, 27 Dec 2011 15:49:04 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <4ef31672$0$6574$9b4e6d93@newsspool3.arcor-online.net> <9lgls6FticU1@mid.individual.net> <4ef34839$0$7623$9b4e6d93@newsspool1.arcor-online.net> <4ef3acd0$0$6642$9b4e6d93@newsspool2.arcor-online.net> <9lobhaF9adU1@mid.individual.net> <4ef9aaad$0$6643$9b4e6d93@newsspool2.arcor-online.net> <9lul3qFmgaU1@mid.individual.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 X-Trace: pcls6.std.com 1325018945 11745 192.74.137.71 (27 Dec 2011 20:49:05 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Tue, 27 Dec 2011 20:49:05 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:9TTixNuRcNLVy1A6gshxZDmeTQQ= Content-Type: text/plain; charset=us-ascii Date: 2011-12-27T15:49:04-05:00 List-Id: Niklas Holsti writes: > Whether a Boolean array is packed to Component_Size = 1, with no gaps, > depends on the Ada compiler. It is not a hard requirement in the Ada RM, > as I understand it. For any compiler that supports the SP annex (which pretty-much all do), it is a hard requirement. But if you're depending on Component_Size = 1 for the logical correctness of your program, it's better to say "for T'Component_Size use 1;" (which also must be supported if the SP annex applies). > All of RM 13.2 is non-binding recommendation; the text defines the > recommended level of support, using "should". The only "shall" in 13.2 > is in a legality rule. No properties of packed Boolean arrays are > "guaranteed" by 13.2. Right, but C.2(2) turns all those "should"s into "shall"s. > But there is not even a recommendation on the order in which bits in a > packed Boolean array are indexed, as far as I can see. True, but in practice, it will follow the endianness of the machine. Likewise, the RM doesn't say which bits of an integer represent what, but in practice, the implementation is unlikely to make bit 17 be the high-order bit of a 32-bit integer. ;-) I'd prefer these rules to be nailed down better. But they're not, so you really have no choice but to rely to some extent on compilers doing sensible things. > Sure, if your program is too slow (but works) using packed Boolean > arrays, you can try to speed it up by using modular types instead (but > it might not become faster). That says nothing about portability; if you > were happy with the limited (IMO) portability of packed Boolean arrays, > you will not lose portability by moving to modular types (but you may > have to find out in which order your Ada compiler indexes packed Boolean > arrays, in order to transform your program correctly). GNAT turns small packed arrays into modular integers internally, so you should expect to get the same efficiency. - Bob