6.3.2 Inline Expansion of Subprograms
1
[Subprograms may be expanded in line at the call
site.]
Syntax
2/3
3/3
Legality Rules
4/3
{
AI05-0229-1}
The pragma
shall apply to one or more callable entities or generic subprograms.
Static Semantics
5/3
{
AI05-0229-1}
For If
a pragma Inline
applies to a callable entity
or,
this indicates that inline expansion is desired for all calls to that
entity. If a pragma
Inline applies to a generic subprogram,
the
following language-defined representation aspect may be specified: this
indicates that inline expansion is desired for all calls to all instances
of that generic subprogram.
5.1/3
Inline
The type of aspect Inline is Boolean. When aspect
Inline is True for a callable entity, inline expansion is desired for
all calls to that entity. When aspect Inline is True for a generic subprogram,
inline expansion is desired for all calls to all instances of that generic
subprogram.
5.2/3
If directly specified,
the aspect_definition
shall be a static expression. [This aspect is never inherited;] if not
directly specified, the aspect is False.
5.a/3
Aspect Description
for Inline: For
efficiency, Inline calls are requested for a subprogram.
5.b/3
This
paragraph was deleted.Ramification:
{
AI05-0229-1}
Note that inline expansion is desired no matter
what name is used in the call. This allows one to request inlining for
only one of several overloaded subprograms as follows:
5.c/3
This paragraph
was deleted.package IO is
procedure Put(X : in Integer);
procedure Put(X : in String);
procedure Put(X : in Character);
private
procedure Character_Put(X : in Character) renames Put;
pragma Inline(Character_Put);
end IO;
5.d/3
This paragraph
was deleted.with IO; use IO;
procedure Main is
I : Integer;
C : Character;
begin
...
Put(C); -- Inline expansion is desired.
Put(I); -- Inline expansion is NOT desired.
end Main;
5.e/3
Ramification: {
AI05-0229-1}
The meaning of a subprogram can be changed by
inline
expansion as requested by aspect a pragma
Inline only in the presence of failing checks (see
11.6).
Implementation Permissions
6/3
{
AI05-0229-1}
For each call, an implementation is free to follow or to ignore the recommendation
determined expressed
by the
Inline aspect pragma.
6.a
Ramification: Note, in particular, that
the recommendation cannot always be followed for a recursive call, and
is often infeasible for entries. Note also that the implementation can
inline calls even when no such desire was expressed via
the Inline aspect by a pragma, so
long as the semantics of the program remains unchanged.
6.1/3
6.b/3
Reason: This
is allowed for Ada 83 compatibility. This is only a permission as this
usage is considered obsolescent.
6.c/3
7/3
7 {
AI05-0229-1}
The name
in a pragma
Inline can denote more than one entity in the case of overloading. Such
a pragma applies
to all of the denoted entities.
Incompatibilities With Ada 83
7.a/3
This paragraph
was deleted. {
AI95-00309-01}
{
AI05-0229-1}
A
pragma Inline cannot refer to a subprogram_body
outside of that body. The pragma can be given inside of the subprogram
body. Ada 2005 adds an Implementation Permission to allow this usage
for compatibility (and Ada 95 implementations also can use this permission),
but implementations do not have to allow such pragmas.
Extensions to Ada 83
7.b/3
Extensions to Ada 95
7.c/3
Extensions to Ada 2005
7.d/3
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe