From: "Jeffrey R. Carter" <spam@spam.com>
Subject: Re: Choice of variant record discriminant (design question)
Date: Wed, 26 Oct 2005 17:52:06 GMT
Date: 2005-10-26T17:52:06+00:00 [thread overview]
Message-ID: <anP7f.47$8c5.15@newsread3.news.pas.earthlink.net> (raw)
In-Reply-To: <m2acgwmpsu.fsf@hugin.crs4.it>
Jacob Sparre Andersen wrote:
> I have declared a record type like this:
>
> type Preprocessed_Parameters (Measurement_Count : Natural := 0) is
> record
> case Measurement_Count is
> when 0 =>
> null;
> when others =>
> Mean_Value : Scalar;
> Scaled_Variance : Scalar;
> end case;
> end record;
Your record has 2 variants, so your discriminant should have 2 values.
> I can't do this, since the discriminant has to be static. The obvious
> solution to the problem is to change the record declaration into:
>
> type Preprocessed_Parameters (Empty : Boolean := True) is
> record
> case Empty is
> when True =>
> null;
> when False =>
> Measurement_Count : Positive;
> Mean_Value : Scalar;
> Scaled_Variance : Scalar;
> end case;
> end record;
>
> but I have a feeling there ought to be a more elegant solution. Does
> somebody have a suggestion or two?
Now you have a discriminant with 2 values controlling a record with 2 variants.
I find that more elegant than your 1st version.
--
Jeff Carter
"We burst our pimples at you."
Monty Python & the Holy Grail
16
next prev parent reply other threads:[~2005-10-26 17:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-26 12:21 Choice of variant record discriminant (design question) Jacob Sparre Andersen
2005-10-26 13:14 ` christoph.grein
2005-10-26 13:26 ` Jacob Sparre Andersen
2005-10-26 17:52 ` Jeffrey R. Carter [this message]
2005-10-26 19:52 ` Randy Brukardt
2005-10-31 15:53 ` Jacob Sparre Andersen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox