comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: Calculate and set Parity
Date: 16 Sep 2002 14:14:22 -0400
Date: 2002-09-16T18:24:06+00:00	[thread overview]
Message-ID: <uznuhajk1.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: am518n$qbq$1@newstoo.ericsson.se

"Sebastian" <sebastian.madunic@avionics.saab.se> 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



  reply	other threads:[~2002-09-16 18:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-16 16:42 Calculate and set Parity Sebastian
2002-09-16 18:14 ` Stephen Leake [this message]
2002-09-16 18:58 ` Jeffrey Carter
2002-09-16 19:51   ` tmoran
2002-09-17  1:36   ` tmoran
2002-09-17 22:05 ` Nick Roberts
2002-09-17 23:23   ` tmoran
2002-09-18  0:17   ` tmoran
2002-09-18 20:25     ` Nick Roberts
2002-09-18  2:52 ` SteveD
2002-09-18 18:29 ` Parity using 'Write, was " tmoran
2002-09-18 18:47   ` David C. Hoos
2002-09-18 22:17     ` tmoran
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox