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,9f99a33281d5072c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!16g2000prp.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: When a conditional expression is static, where can it be used? Date: Wed, 30 Jun 2010 12:12:17 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <4c2b1ecb$0$7670$9b4e6d93@newsspool1.arcor-online.net> <555e3a37-c709-4b9b-995a-907da862d4b7@m40g2000prc.googlegroups.com> <12ok8wnj6k4sw$.ravumwbhfb1h$.dlg@40tude.net> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1277925138 30743 127.0.0.1 (30 Jun 2010 19:12:18 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 30 Jun 2010 19:12:18 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 16g2000prp.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:12051 Date: 2010-06-30T12:12:17-07:00 List-Id: On Jun 30, 10:35=A0am, "Dmitry A. Kazakov" wrote: > On Wed, 30 Jun 2010 07:39:24 -0700 (PDT), Adam Beneschan wrote: > > On Jun 30, 3:39 am, Georg Bauhaus > > wrote: > >> A totally meaningless example just to illustrate > >> the question: What is it that a compiler must report > >> for the case statement below, if anything? > > > The choice "Sa" is not covered by any alternative. =A0Other than that, = I > > don't think there's anything wrong with the CASE statement, and if you > > had included a "when others =3D>" alternative I think it would be > > legal. =A0I'm not sure what potential problem you were trying to > > illustrate. > > Let me propose this one instead: > > =A0 type DOW is (Mo, Tu, We, Th, Fr, Sa, So); > > =A0 case D is > =A0 when (if D =3D Mo then Tu else Mo) =3D> P; > =A0 when (if D =3D Tu then Tu else Mo) =3D> Q; > =A0 when We..So =3D> R; > =A0 end case; > > The above is equivalent to: > > =A0 case D is > =A0 when Tu =3D> P; > =A0 when Mo =3D> Q; > =A0 when We..So =3D> R; > =A0 end case; > > But as Pascal suggested, it should not compile because D is not static. Ummm, not quite, because (1) Pascal didn't say anything about *why* he thought it shouldn't compile (his entire statement was "This should not compile I would say"), and (2) in the OP's original example, D *is* static. In your example, you're right that it shouldn't compile because D is not static, but that's a different issue. (Well, I *assume* D isn't static. Since your example doesn't include a declaration of D, I can't tell.) > As for the problem Georg had in mid. Maybe it is this. Let you have some > function, say Gamma function. Now, > > =A0 =A0x : constant :=3D 0.1; > =A0 =A0Gx : constant :=3D Gamma (1.1); -- Illegal, what a pity > > Let us open the table of Gamma, scan it, and write something like: > > =A0 =A0(if x < 0.0 then ... elsif x < 0.01 then ... ) > > This wonderful static function can then copied and pasted everywhere you > wanted to evaluate Gamma at compile time. Is it legal? Gamma cannot be a static function (4.9(18-22)). You cannot write a static function (other than an enumeration literal, which is technically a static function). -- Adam