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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1514d4f994aed7aa X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.velia.net!newsfeed.vmunix.org!peer-uk.news.demon.net!kibo.news.demon.net!mutlu.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: generic function and overloading Date: Thu, 18 Oct 2007 21:20:52 +0100 Organization: Pushface Message-ID: References: <1192688972.967825.31130@t8g2000prg.googlegroups.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1192738850 21227 62.49.19.209 (18 Oct 2007 20:20:50 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Thu, 18 Oct 2007 20:20:50 +0000 (UTC) Cancel-Lock: sha1:ajz+WGcEiQpNDoPE7lXOfjXkvMo= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (darwin) Xref: g2news2.google.com comp.lang.ada:2486 Date: 2007-10-18T21:20:52+01:00 List-Id: Robert A Duff writes: > But do you really want to do arithmetic on these types, > as well as setting/clearing bits? If all you want to > do is set/clear bits, you might want to consider using > a packed array of Boolean. Then to set the Nth bit you > can say: > > X (N) := True; > > Alternatively, a packed array of type Bit, where: > > type Bit is range 0..1; > > If the individual bit numbers have some specific meaning, > the index type could be an enumeration type. Will give surprising results on a big-endian machine. At least code using shifts and masks is portable if gruesome -- and no more gruesome than code I've written which says type Unrepresented is .. Internal : Unrepresented; ... if System.Default_Bit_Order = System.High_Order_First then declare type Represented is .. for Represented use .. -- record rep with big-endian usage External : constant Represented := Internal; begin Output (External); end; else -- equivalent for l-e