6.8 Expression Functions
Syntax
Name Resolution Rules
Legality Rules
Ramification: This can only fail if the
discriminant is an access to a part of a non-aliased parameter, as there
can be no local declarations here.
Discussion: {
AI12-0005-1}
We don't need to repeat any of the other Legality Rules for return statements
since none of them can fail here: the implicit return statement has to
apply to this function (and isn't nested in something), there clearly
is a return statement in this function, and the static class-wide accessibility
check cannot fail as a tagged type cannot be declared locally in an expression
function.
Static Semantics
Dynamic Semantics
Discussion: The last sentence effectively
means that all of the dynamic wording in
6.5
applies as needed, and we don't have to repeat it here.
Examples
{
AI05-0177-1}
function Is_Origin (P :
in Point)
return Boolean
is --
see 3.9
(P.X = 0.0
and P.Y = 0.0);
Extensions to Ada 2005
{
AI05-0177-1}
Expression functions are new in Ada 2012.
Extensions to Ada 2012
{
AI12-0157-1}
A
aggregate
can directly be the return expression of an expression function. This
eliminates the double parentheses that otherwise would be necessary.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe