6.8 Expression Functions
Syntax
Name Resolution Rules
Static Semantics
A
potentially static
expression is defined in the same way as a static expression except
that
a name denoting a formal parameter of an expression
function is a potentially static expression; and
each use of “static expression” in
the definition of “static expression” is replaced with a
corresponding use of “potentially static expression” in the
definition of “potentially static expression”.
The following language-defined
representation aspect may be specified for an expression function:
Static
The type of aspect Static is Boolean. When aspect Static is True for
an expression function, the function is a
static expression function.
If directly specified, the
aspect_definition
shall be a static
expression.
The Static value for an inherited function is True if some corresponding
primitive function of the parent or progenitor type is a static expression
function; otherwise, if not directly specified, the aspect is False.
A static expression function is a static function;
see
4.9.
Legality Rules
is not a completion;
has an
expression
that is a potentially static expression;
contains no calls to itself;
each parameter (if any) is of mode in and
is of a static subtype;
has a result subtype that is a static subtype;
has no applicable precondition or postcondition
expression; and
for result type
R, if the function is a
boundary entity for type
R (see
7.3.2),
no type invariant applies to type
R; if
R has a component
type
C, a similar rule applies to
C.
Paragraph 6 was deleted.
Dynamic Semantics
The elaboration of an
expression_function_declaration
has no other effect than to establish that the expression function can
be called without failing the Elaboration_Check.
Examples
Example of an expression
function:
function Is_Origin (P :
in Point)
return Boolean
is --
see 3.9
(P.X = 0.0
and P.Y = 0.0);
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe