comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: When a conditional expression is static, where can it be used?
Date: Wed, 30 Jun 2010 19:35:38 +0200
Date: 2010-06-30T19:35:36+02:00	[thread overview]
Message-ID: <12ok8wnj6k4sw$.ravumwbhfb1h$.dlg@40tude.net> (raw)
In-Reply-To: 555e3a37-c709-4b9b-995a-907da862d4b7@m40g2000prc.googlegroups.com

On Wed, 30 Jun 2010 07:39:24 -0700 (PDT), Adam Beneschan wrote:

> On Jun 30, 3:39�am, Georg Bauhaus <rm.dash-bauh...@futureapps.de>
> 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.  Other than that, I
> don't think there's anything wrong with the CASE statement, and if you
> had included a "when others =>" alternative I think it would be
> legal.  I'm not sure what potential problem you were trying to
> illustrate.

Let me propose this one instead: 

 � �type DOW is (Mo, Tu, We, Th, Fr, Sa, So);

 � �case D is
 � � � when (if D = Mo then Tu else Mo) => P;
 � � � when (if D = Tu then Tu else Mo) => Q;
 � � � when We..So => R;
 � �end case;

The above is equivalent to:

 � �case D is
 � � � when Tu => P;
 � � � when Mo => Q;
 � � � when We..So => R;
 � �end case;

But as Pascal suggested, it should not compile because D is not static. 

As for the problem Georg had in mid. Maybe it is this. Let you have some
function, say Gamma function. Now,

   x : constant := 0.1;
   Gx : constant := Gamma (1.1); -- Illegal, what a pity

Let us open the table of Gamma, scan it, and write something like:

   (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?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2010-06-30 17:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-30 10:39 When a conditional expression is static, where can it be used? Georg Bauhaus
2010-06-30 11:25 ` Pascal Obry
2010-06-30 14:39 ` Adam Beneschan
2010-06-30 17:35   ` Dmitry A. Kazakov [this message]
2010-06-30 19:12     ` Adam Beneschan
2010-06-30 20:00       ` Dmitry A. Kazakov
2010-06-30 20:16         ` Adam Beneschan
2010-07-01 17:04       ` Pascal Obry
2010-06-30 20:05     ` Georg Bauhaus
2010-06-30 20:29       ` Adam Beneschan
2010-06-30 20:45       ` Dmitry A. Kazakov
replies disabled

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