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,553a6b79b2471571 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s22.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How do you bitwise operations in Ada '83 and '95 References: <1153244316.853254.291560@m79g2000cwm.googlegroups.com> <1153248800.834457.183940@p79g2000cwp.googlegroups.com> <1153258362.266358.15200@h48g2000cwc.googlegroups.com> <1153281313.491512.88760@75g2000cwc.googlegroups.com> In-Reply-To: <1153281313.491512.88760@75g2000cwc.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.176 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s22 1153283875 12.201.97.176 (Wed, 19 Jul 2006 04:37:55 GMT) NNTP-Posting-Date: Wed, 19 Jul 2006 04:37:55 GMT Date: Wed, 19 Jul 2006 04:37:55 GMT Xref: g2news2.google.com comp.lang.ada:5798 Date: 2006-07-19T04:37:55+00:00 List-Id: jimmaureenrogers@worldnet.att.net wrote: > > Actually it does not work exactly the same. The algorithm is > exactly the same, and the same numbers are produced, but the > packed array of bits executes faster on my machine by a factor > of 3 and uses significantly less space (by a factor of 8). "The algorithm is the same and the same numbers are produced" = "works the same". Performance may differ, but behavior is the same. Since performance is a function of many things in addition to the SW, only behavior is a meaningful comparison. No doubt there is a platform/OS/compiler combination such that the unpacked version would run faster than the packed version does on your machine. > Your definition of bit-wise appears to me to be based upon the > desire to use a low level abstraction to access the bits. My > definition includes all abstractions that allow access to > individual bits. When I only programmed in C, I only > thought of bit-wise access in low level abstractions. Since I > have programmed in Ada I think of bit-wise operations in > many abstraction levels. "Bitwise operations" is an inherently low-level concept. At a high level, your abstraction is a set. If we treat that as a high-level abstraction, then we hide the implementation, and neither bits nor Booleans appear in the handling of sets in the main program. An array of Booleans, packed or not, is only one possible implementation of a set. We could rewrite your program using the ordered-set package from the Ada-0X data-structures library and get the same behavior. It would not involve any bit-level access, though. However, you raise an important point, and that is that we should ask the OP what he is trying to achieve. It may be that low-level concepts such as bitwise operations are an inappropriate way to approach the problem, and instead of showing how to do low-level things, we should be advising on appropriate high-level abstractions. -- Jeff Carter "I'm a lumberjack and I'm OK." Monty Python's Flying Circus 54