Contents   Index   Search   Previous   Next


6.3.2 Inline Expansion of Subprograms

1
   [Subprograms may be expanded in line at the call site.]

Syntax

2
{program unit pragma (Inline) [partial]} {pragma, program unit (Inline) [partial]} The form of a pragma Inline, which is a program unit pragma (see 10.1.5), is as follows:
3
  pragma Inline(name {, name});

Legality Rules

4
   The pragma shall apply to one or more callable entities or generic subprograms.

Static Semantics

5
   If a pragma Inline applies to a callable entity, this indicates that inline expansion is desired for all calls to that entity. If a pragma Inline applies to a generic subprogram, this indicates that inline expansion is desired for all calls to all instances of that generic subprogram.
5.a
Ramification: 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.b
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.c
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.d
Ramification: The meaning of a subprogram can be changed by a pragma Inline only in the presence of failing checks (see 11.6).

Implementation Permissions

6
   For each call, an implementation is free to follow or to ignore the recommendation expressed by the 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 by a pragma, so long as the semantics of the program remains unchanged.
NOTES
7
6  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.

Extensions to Ada 83

7.a
{extensions to Ada 83} A pragma Inline is allowed inside a subprogram_body if there is no corresponding subprogram_declaration. This is for uniformity with other program unit pragmas.

Contents   Index   Search   Previous   Next   Legal