Ada Conformity Assessment Authority      Home Conformity Assessment   Test Suite ARGAda Standard
 
Overview of Ada 2022
Jeff Cousins
Contents   Index   Search   Previous   Next 

7.5 Static expression functions

The aspect Static is introduced by Static expression functions (AI12-0075) (see RM 6.8). It can only be applied to an expression function, and requests that it be regarded as a static function.
When called in a context that requires a static expression, the actual parameters of the expression function need to be static. For example, if we declare:
function If_Then_Else (Flag : Boolean; X, Y : Integer) return Integer is
   (if Flag then X else Y) with Static;
and then attempt to declare:
V : Integer := 10;
X : constant := If_Then_Else (True, 37, V); -- Error.
we get an error at compile time since V is not a static expression.
Predefined shifts and rotates should be static (AI12-0385) applies this new aspect Static to the predefined shift and rotate functions of package Interfaces.

Contents   Index   Search   Previous   Next 
© 2021, 2022 Jeff Cousins