GNAT Reference Manual: Implementation Defined Aspects

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

# 2. Implementation Defined Aspects

Ada defines (throughout the Ada 2012 reference manual, summarized in Annex K) a set of aspects that can be specified for certain entities. These language defined aspects are implemented in GNAT in Ada 2012 mode and work as described in the Ada 2012 Reference Manual.

In addition, Ada 2012 allows implementations to define additional aspects whose meaning is defined by the implementation. GNAT provides a number of these implementation-defined aspects which can be used to extend and enhance the functionality of the compiler. This section of the GNAT reference manual describes these additional aspects.

Note that any program using these aspects may not be portable to other compilers (although GNAT implements this set of aspects on all platforms). Therefore if portability to other compilers is an important consideration, you should minimize the use of these aspects.

Note that for many of these aspects, the effect is essentially similar to the use of a pragma or attribute specification with the same name applied to the entity. For example, if we write:

    type R is range 1 .. 100
      with Value_Size => 10;

then the effect is the same as:

    type R is range 1 .. 100;
    for R'Value_Size use 10;

and if we write:

    type R is new Integer
      with Shared => True;

then the effect is the same as:

    type R is new Integer;
    pragma Shared (R);

In the documentation below, such cases are simply marked as being equivalent to the corresponding pragma or attribute definition clause.

> Aspect Abstract_State |  |
> Annotate |  |
> Aspect Async_Readers |  |
> Aspect Async_Writers |  |
> Aspect Contract_Cases |  |
> Aspect Depends |  |
> Aspect Dimension |  |
> Aspect Dimension_System |  |
> Aspect Effective_Reads |  |
> Aspect Effective_Writes |  |
> Aspect Favor_Top_Level |  |
> Aspect Global |  |
> Aspect Initial_Condition |  |
> Aspect Initializes |  |
> Aspect Inline_Always |  |
> Aspect Invariant |  |
> Aspect Iterable |  |
> Aspect Linker_Section |  |
> Aspect Lock_Free |  |
> Aspect Object_Size |  |
> Aspect Part_Of |  |
> Aspect Persistent_BSS |  |
> Aspect Predicate |  |
> Aspect Pure_Function |  |
> Aspect Refined_Depends |  |
> Aspect Refined_Global |  |
> Aspect Refined_Post |  |
> Aspect Refined_State |  |
> Aspect Remote_Access_Type |  |
> Aspect Scalar_Storage_Order |  |
> Aspect Shared |  |
> Aspect Simple_Storage_Pool |  |
> Aspect Simple_Storage_Pool_Type |  |
> Aspect SPARK_Mode |  |
> Aspect Suppress_Debug_Info |  |
> Aspect Test_Case |  |
> Aspect Thread_Local_Storage |  |
> Aspect Universal_Aliasing |  |
> Aspect Universal_Data |  |
> Aspect Unmodified |  |
> Aspect Unreferenced |  |
> Aspect Unreferenced_Objects |  |
> Aspect Value_Size |  |
> Aspect Warnings |  |

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Abstract_State

This aspect is equivalent to pragma `Abstract_State`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Annotate

There are three forms of this aspect (where ID is an identifier, and ARG is a general expression).

`Annotate => ID`
  Equivalent to `pragma Annotate (ID, Entity => Name);`

`Annotate => (ID)`
  Equivalent to `pragma Annotate (ID, Entity => Name);`

`Annotate => (ID ,ID {, ARG})`
  Equivalent to `pragma Annotate (ID, ID {, ARG}, Entity => Name);`

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Async_Readers

This aspect is equivalent to pragma `Async_Readers`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Async_Writers

This aspect is equivalent to pragma `Async_Writers`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Contract_Cases

This aspect is equivalent to pragma `Contract_Cases`, the sequence of clauses being enclosed in parentheses so that syntactically it is an aggregate.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Depends

This aspect is equivalent to pragma `Depends`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Dimension

The `Dimension` aspect is used to specify the dimensions of a given subtype of a dimensioned numeric type. The aspect also specifies a symbol used when doing formatted output of dimensioned quantities. The syntax is:

    with Dimension =>
      ([Symbol =>] SYMBOL, DIMENSION_VALUE {, DIMENSION_Value})

    SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL

    DIMENSION_VALUE ::=
      RATIONAL
    | others               => RATIONAL
    | DISCRETE_CHOICE_LIST => RATIONAL

    RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]

This aspect can only be applied to a subtype whose parent type has a `Dimension_Systen` aspect. The aspect must specify values for all dimensions of the system. The rational values are the powers of the corresponding dimensions that are used by the compiler to verify that physical (numeric) computations are dimensionally consistent. For example, the computation of a force must result in dimensions (L => 1, M => 1, T => -2). For further examples of the usage of this aspect, see package `System.Dim.Mks`. Note that when the dimensioned type is an integer type, then any dimension value must be an integer literal.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Dimension_System

The `Dimension_System` aspect is used to define a system of dimensions that will be used in subsequent subtype declarations with `Dimension` aspects that reference this system. The syntax is:

    with Dimension_System => (DIMENSION {, DIMENSION});

    DIMENSION ::= ([Unit_Name   =>] IDENTIFIER,
                   [Unit_Symbol =>] SYMBOL,
                   [Dim_Symbol  =>] SYMBOL)

    SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL

This aspect is applied to a type, which must be a numeric derived type (typically a floating-point type), that will represent values within the dimension system. Each `DIMENSION` corresponds to one particular dimension. A maximum of 7 dimensions may be specified. `Unit_Name` is the name of the dimension (for example `Meter`). `Unit_Symbol` is the shorthand used for quantities of this dimension (for example `m` for `Meter`). `Dim_Symbol` gives the identification within the dimension system (typically this is a single letter, e.g. `L` standing for length for unit name `Meter`). The `Unit_Symbol` is used in formatted output of dimensioned quantities. The `Dim_Symbol` is used in error messages when numeric operations have inconsistent dimensions.

GNAT provides the standard definition of the International MKS system in the run-time package `System.Dim.Mks`. You can easily define similar packages for cgs units or British units, and define conversion factors between values in different systems. The MKS system is characterized by the following aspect:

       type Mks_Type is new Long_Long_Float with
         Dimension_System => (
           (Unit_Name => Meter,    Unit_Symbol => 'm',   Dim_Symbol => 'L'),
           (Unit_Name => Kilogram, Unit_Symbol => "kg",  Dim_Symbol => 'M'),
           (Unit_Name => Second,   Unit_Symbol => 's',   Dim_Symbol => 'T'),
           (Unit_Name => Ampere,   Unit_Symbol => 'A',   Dim_Symbol => 'I'),
           (Unit_Name => Kelvin,   Unit_Symbol => 'K',   Dim_Symbol => ''),
           (Unit_Name => Mole,     Unit_Symbol => "mol", Dim_Symbol => 'N'),
           (Unit_Name => Candela,  Unit_Symbol => "cd",  Dim_Symbol => 'J'));

Note that in the above type definition, we use the symbol `@` to represent a theta character (avoiding the use of extended Latin-1 characters in this context).

See section "Performing Dimensionality Analysis in GNAT" in the GNAT Users Guide for detailed examples of use of the dimension system.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Effective_Reads

This aspect is equivalent to pragma `Effective_Reads`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Effective_Writes

This aspect is equivalent to pragma `Effective_Writes`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Favor_Top_Level

This aspect is equivalent to pragma `Favor_Top_Level`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Global

This aspect is equivalent to pragma `Global`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Initial_Condition

This aspect is equivalent to pragma `Initial_Condition`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Initializes

This aspect is equivalent to pragma `Initializes`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Inline_Always

This aspect is equivalent to pragma `Inline_Always`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Invariant

This aspect is equivalent to pragma `Invariant`. It is a synonym for the language defined aspect `Type_Invariant` except that it is separately controllable using pragma `Assertion_Policy`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Iterable

This aspect is used in the GNAT-defined formal container packages, to provide a light-weight mechanism for loops over such containers, without the overhead imposed by the tampering checks of standard Ada2012 iterators. The value of the aspect is a aggregate with four named components: First, Next, Has_Element, and Element. The following is a typical example of use:

    type List is private with
        Iterable => (First        => First_Element,
                     Next         => Advance,
                     Has_Element  => Get_Element,
                     Element      => List_Element);

- The value denoted by `First` must denote a primitive operation of the container type that returns a Cursor, which must a be a type declared in the container package.
- The value of `Next` is a primitive operation of the container type that takes a cursor and yields a cursor.
- `Has_Element` is an operation that applies to a cursor a yields an element of the container.
- `Element` is the type of the elements of the container type, and thus the result of the function denoted by Has_Element.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Linker_Section

This aspect is equivalent to an `Linker_Section` pragma.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Lock_Free

This aspect is equivalent to pragma `Lock_Free`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Object_Size

This aspect is equivalent to an `Object_Size` attribute definition clause.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Part_Of

This aspect is equivalent to pragma `Part_Of`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Persistent_BSS

This aspect is equivalent to pragma `Persistent_BSS`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Predicate

This aspect is equivalent to pragma `Predicate`. It is thus similar to the language defined aspects `Dynamic_Predicate` and `Static_Predicate` except that whether the resulting predicate is static or dynamic is controlled by the form of the expression. It is also separately controllable using pragma `Assertion_Policy`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Pure_Function

This aspect is equivalent to pragma `Pure_Function`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Refined_Depends

This aspect is equivalent to pragma `Refined_Depends`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Refined_Global

This aspect is equivalent to pragma `Refined_Global`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Refined_Post

This aspect is equivalent to pragma `Refined_Post`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Refined_State

This aspect is equivalent to pragma `Refined_State`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Remote_Access_Type

This aspect is equivalent to pragma `Remote_Access_Type`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Scalar_Storage_Order

This aspect is equivalent to a `Scalar_Storage_Order` attribute definition clause.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Shared

This aspect is equivalent to pragma `Shared`, and is thus a synonym for aspect `Atomic`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Simple_Storage_Pool

This aspect is equivalent to a `Simple_Storage_Pool` attribute definition clause.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Simple_Storage_Pool_Type

This aspect is equivalent to pragma `Simple_Storage_Pool_Type`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect SPARK_Mode

This aspect is equivalent to pragma `SPARK_Mode` and may be specified for either or both of the specification and body of a subprogram or package.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Suppress_Debug_Info

This aspect is equivalent to pragma `Suppress_Debug_Info`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Test_Case

This aspect is equivalent to pragma `Test_Case`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Thread_Local_Storage

This aspect is equivalent to pragma `Thread_Local_Storage`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Universal_Aliasing

This aspect is equivalent to pragma `Universal_Aliasing`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Universal_Data

This aspect is equivalent to pragma `Universal_Data`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Unmodified

This aspect is equivalent to pragma `Unmodified`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Unreferenced

This aspect is equivalent to pragma `Unreferenced`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Unreferenced_Objects

This aspect is equivalent to pragma `Unreferenced_Objects`.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Value_Size

This aspect is equivalent to a `Value_Size` attribute definition clause.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

## Aspect Warnings

This aspect is equivalent to the two argument form of pragma `Warnings`, where the first argument is `ON` or `OFF` and the second argument is the entity.

[ << ] | [ >> ] |  |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by GNAT Mailserver on April, 17 2014 using texi2html