comp.lang.ada
 help / color / mirror / Atom feed
From: johnherro@aol.com (John Herro)
Subject: Re: Supplying a parameter for "digits"
Date: 1996/08/19
Date: 1996-08-19T00:00:00+00:00	[thread overview]
Message-ID: <4v9mud$nad@newsbf02.news.aol.com> (raw)
In-Reply-To: 4url7g$j6f@goanna.cs.rmit.edu.au


ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe)
would like to write
> generic
>    type Coord is digits <>;
>    type Value is digits <>;
>    package Example is
>       type Product is
>          digits Integer'Max(Coord'Digits, Value'Digits);
but the last line quoted won't compile because the expression isn't
static.

     I don't have the answer, but I can shed a *little* light on the
subject.
     It would *seem* from 4.9(1) that anything that can be evaluated at
compile time "should" be considered a static expression.  However, the
forms that actually *are* considered static expressions are listed in
4.9(2) through 4.9(13).  Unfortunately, what you want to write isn't on
the list.  I have to admit, though, that (6) and (7) come tantalizingly
close.
     Last January there was a thread here about the expression A(0), where
A is a *constant* array.  You would certainly think that A(0) "ought" to
be a static expression, but it isn't.  Of course, a smart compiler might
evaluate A(0) at compile time and use the result in optimizations, but
unfortunately it still doesn't count as a static expression for the rules
of Ada syntax.
     The only rationale mentioned in the earlier thread is that they "had
to draw the line somewhere" (in terms of how complex an expression could
be considered static).  They drew it in 4.9(2) through 4.9(13).
     Unfortunately, I don't know how to set up your generic package the
way you want.  Anyone have any ideas?
- John Herro
Software Innovations Technology
http://members.aol.com/AdaTutor
ftp://members.aol.com/AdaTutor




  reply	other threads:[~1996-08-19  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-14  0:00 Supplying a parameter for "digits" Richard A. O'Keefe
1996-08-19  0:00 ` John Herro [this message]
1996-08-19  0:00   ` Kevin J. Weise
replies disabled

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