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-Thread: 103376,195f9d06474696b0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g49g2000cwa.googlegroups.com!not-for-mail From: christoph.grein@eurocopter.com Newsgroups: comp.lang.ada Subject: Re: Choice of variant record discriminant (design question) Date: 26 Oct 2005 06:14:31 -0700 Organization: http://groups.google.com Message-ID: <1130332471.078782.145370@g49g2000cwa.googlegroups.com> References: NNTP-Posting-Host: 80.156.44.1 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1130332476 28975 127.0.0.1 (26 Oct 2005 13:14:36 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 26 Oct 2005 13:14:36 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.0.1) Gecko/20020920 Netscape/7.0,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 webwasher (Webwasher 5.2.0.1901) Complaints-To: groups-abuse@google.com Injection-Info: g49g2000cwa.googlegroups.com; posting-host=80.156.44.1; posting-account=nIrLjQ0AAAAgar8ljl4x6DQaFY__mhF4 Xref: g2news1.google.com comp.lang.ada:5957 Date: 2005-10-26T06:14:31-07:00 List-Id: 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; > > I would like to return an object of that type from a function using > this piece of code: > declare Parm: Preprocessed_Parameters (Measurement_Count => Count); begin > if Count = 0 then null; > else > [...] Parm.Mean_Value := Mean; Parm.Scaled_Variance := Sum; return Parm; > end if; > > I can't do this, since the discriminant has to be static.