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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,255a2533fba89f5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-09-16 13:08:57 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Calculate and set Parity Date: 16 Sep 2002 14:14:22 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1032200646 15863 128.183.220.71 (16 Sep 2002 18:24:06 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 16 Sep 2002 18:24:06 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:29048 Date: 2002-09-16T18:24:06+00:00 List-Id: "Sebastian" writes: > Hi, > > I need a subroutine that calculates the parity of a record type with the > size of 16 bits. Is there some nice way > to do this? I currently have a solution were I use Unchecked_Conversion to > convert my variable to an > array booleans, then I calculate every true etc. Is there some way to do > this without using Unchecked_Conversion. Why do you not want to use Unchecked_Conversion? The calculation of parity inherently involves breaking the abstraction of the type. Parity is defined in terms of bits; the normal operations on the type are not. Unchecked_Conversion is one mechanism Ada provides to let you break the abstraction of a type. So Unchecked_Conversion _is_ the "nice" way to do this. Unchecked_Conversion is a violation of abstraction. That is not _always_ a bad thing; just _usually_ a bad thing :). -- -- Stephe