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,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8309f2bc055237c4 X-Google-Attributes: gid103376,public From: gdemont@my-deja.com Subject: Re: Bit manipulation Date: 2000/11/08 Message-ID: <8ubhlh$ejv$1@nnrp1.deja.com>#1/1 X-Deja-AN: 691174491 References: <8u8v6n$b7o$1@nnrp1.deja.com> <2WTH$pdrCfOd@eisner.decus.org> <8ub6kt$6nd$1@nnrp1.deja.com> <8ubeq8$cgm$1@nnrp1.deja.com> X-Http-Proxy: 1.0 sitelnet.unine.ch:8080 (Squid/2.1.PATCH2), 1.0 x59.deja.com:80 (Squid/1.1.22) for client 130.125.13.43, 130.125.90.100 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed Nov 08 12:41:22 2000 GMT X-MyDeja-Info: XMYDJUIDgdemont Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.74 (Macintosh; U; PPC) Date: 2000-11-08T00:00:00+00:00 List-Id: > Of course we could give a simple answer involving the > obvious solution of converting Character'Pos values to > a modular type and then doing shifts and masks in the > normal manner, but that would be a disservice. > > I see a *lot* of code that is clearly written by C programmers > and greatly overuses low level bit twiddling techniques that > are appropriate to C but not to Ada. > > If someone simply wants to get a job done in the dirtiest > possible fashion, and wants someone else to do the work, > CLA is not the place to expect free help :-) I'm not sure that Mr Binetti intends to do dirty things. After all, the conversions like Character'Pos <-> modular or signed <-> modular precisely draw the attention about when you enter the realm of bit twiddling on a certain number of bits, and when some bit and bit length have a special meaning. They are verbose enough to be re-found after a while, and to discourage using them when a "* (2**7)" or a "mod 32" suffices. The dirty thing would be e.g. to allow bit twiddling on a signed integer, and this is the cause of fast-rotting code in C or some Pascals; fortunately Ada95 doesn't allow it and has an elegant and efficient solution for that issue. I'm sure the users are adult enough to find the most appropriate formulations for _their_ problems after some weeks of Ada programming; therefore hiding the availability of modular types _is_ a disservice. If one tells them that the only solution to mask bits is to write 20 lines of records definitions with representation clauses, they won't use Ada at all, simply! Gautier Sent via Deja.com http://www.deja.com/ Before you buy.