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.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1e67a7db835cf5a8 X-Google-Attributes: gid103376,public From: Nick Roberts Subject: Re: Binary files vs Portablity vs Ada Date: 1999/11/08 Message-ID: <3826FD9C.37446C29@callnetuk.com>#1/1 X-Deja-AN: 546018971 Content-Transfer-Encoding: 7bit References: <7vt67r$qv0$1@coward.ks.cc.utah.edu> X-Original-NNTP-Posting-Host: da129d247.dialup.callnetuk.com X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: 8 Nov 1999 19:09:13 GMT, da129d247.dialup.callnetuk.com Organization: Computer Consultant MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-11-08T00:00:00+00:00 List-Id: John Halleck wrote: > [how to manipulate file bits portably] I'd have thought you could go a long way towards a portable implementation if you could code an algorithm that can work on words of a parametric size (number of bits), and then use Ada.Streams.Stream_Element'Size as the parameter. Then you can use Ada.Streams.Stream_IO to do input and output directly on (arrays of) stream elements. I think this would bypass any implementation-specific characteristic of reading or writing the data, in practice. To get the bits out of a mod type (portably), you have to resort to arithmetic (X and 2**N), and hope the compiler optimises correctly. I think it's a subject that has been mentioned before in comp.lang.ada, but possibly another suggestion for the next Ada revision might be two new predefined types: type Bit_Integer is mod 2; type Bit_Array is array (Natural range <>) of Bit_Integer; and then a new conversion introduced between Bit_Array (or types derived from it) and any mod type whose modulus was a power of two (and static?). This conversion would stipulate that the bit with the lowest index (in the array) was the bit with the least significance (in the integer). -- Nick Roberts Computer Consultant (UK) http://www.callnetuk.com/home/nickroberts http://www.adapower.com/lab/adaos