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,c5f68ab74d5099ee X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.213.71 with SMTP id nq7mr4477031pbc.2.1323942584358; Thu, 15 Dec 2011 01:49:44 -0800 (PST) Path: lh20ni24785pbb.0!nntp.google.com!news1.google.com!news4.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Interfaces.Shift_Left Date: Thu, 15 Dec 2011 11:51:44 +0200 Organization: Tidorum Ltd Message-ID: <9ktu5mFn31U1@mid.individual.net> References: <18214312-82f5-45c4-b20d-cb530b500929@h3g2000yqa.googlegroups.com> <5f989095-5c1c-4b23-a538-d70f4718b4b1@l19g2000yqc.googlegroups.com> Mime-Version: 1.0 X-Trace: individual.net n3sIqqFGPorFFAJfKY2mowIb5FHBG6LK+QWtBVNcPWHSNq+u6t Cancel-Lock: sha1:cG0TQ1V5s+zf07Ut5B62DtZGnVU= 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-15T11:51:44+02:00 List-Id: On 11-12-15 00:49 , Randy Brukardt wrote: > "awdorrin" wrote in message > news:a76daa61-49f7-4235-af65-11973a012f35@v29g2000yqv.googlegroups.com... >> I understand what you are saying and I do agree in theory. >> >> The situation is that bit shifting is being used to retrieve data of >> various bit lengths and positions from compound records. >> >> For instance, retrieving a 6-bit signed value from a 32-bit field. > > Right. This definitely should be done using record representation clauses if > there is a choice. I'm sorry to say that I disagree, and now always use the shift-and-mask method. I used to be charmed by record representation clauses, until I wanted to write Ada 95 code that was portable between machines with different bit numbering orders. I know that it is claimed that record representation clauses can be written to be portable between different bit numberings. But in my opinion, the schemes that do not use the Bit_Order attribute make the representation clauses ugly and hard to write and read, while the RM language that describes the Bit_Order attribute and its effects has surpassed my understanding whenever I've tried to read it -- I simply could not be sure that it would have the effect that I wanted. I still would like to define the bit-level structure of data in a declarative way, rather than with field-extraction and field-insertion operations, but I have reluctantly concluded that the operational method is better for portable Ada programs, at least in my applications. Another factor in this decision is that in my applications, the raw data (machine instructions for various processors) can actually have several different structures (instruction formats), so an approach using record representation clauses needs as many different record types and unchecked conversions from the raw data (bit-strings or words) to the appropriate record type. The operational approach entirely avoids these conversions. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .