# Ada Programming/Interfacing

## Interfacing

Ada is one of the few languages where interfacing is part of the
language standard. The programmer can interface with other programming
languages, or with the hardware.

## Other programming languages

The language standard defines the interfaces for
C, Cobol and
Fortran. Of course any implementation
might define further interfaces ---
GNAT for example defines an interface
to C++.

Interfacing with other languages is actually provided by pragma
Export,
Import and
Convention.

### Interfacing with C

The package Interfaces.C is used to define C types. C function wrappers
should be used to encapsulate types and functions on the C side. This
way the code is portable and foward-compatible. This is similar to the
way of interfacing with C in Java\'s JNI. Wrappers should be used for:

-   Translating typedefs defined in C includes to types defined in
    Interfaces.C;
-   Using macros and exposing macro values to the Ada side;
-   Using variable parameter list functions;
-   Defining multiple function wrappers for a function that takes weakly
    typed parameters such as a function that takes a char_array or a
    null pointer;
-   Using getters and setters for C structs that depend on operating
    system version or other compile-type aspect;
-   Using pointer arithmetic;
-   Keeping Ada source memory-safe.

#### Example

` Interfaces.C;`\
` System;`\
` Ada.Text_IO;`\
\
` Main `\
`   `` W32_Open_File_Dialog`\
`   `\
`      `` C `` Interfaces.C;`\
`      `` C;`\
`      `\
`      `` OPENFILENAME `` `` System.Address;`\
`      `` Window_Type `` `` System.Address;`\
`      `\
`      `` GetOpenFileName (p : OPENFILENAME) `` C.int;`\
`      `` Import (C, GetOpenFileName, "ada_getopenfilename");`\
`      `\
`      `` Allocate `` OPENFILENAME `\
`        Import => True,`\
`        Convention => C,`\
`        External_Name => "ofn_allocate";`\
`      `\
`      `` Set_Struct_Size (X : OPENFILENAME) `\
`        Import => True,`\
`        Convention => C,`\
`        External_Name => "ofn_set_struct_size";`\
`      `\
`      `` Set_Owner (X : OPENFILENAME; Owner : Window_Type) `\
`        Import => True,`\
`        Convention => C,`\
`        External_Name => "ofn_set_owner";`\
`      `\
`      `` Set_File (X : OPENFILENAME; File : char_array; Length : C.int) `\
`        Import => True,`\
`        Convention => C,`\
`        External_Name => "ofn_set_file";`\
`      `\
`      `` Set_Filter (X : OPENFILENAME; Filter : char_array);`\
`      `` Import (C, Set_Filter, "ofn_set_filter");`\
`      `\
`      `` Set_Filter_Index (X : OPENFILENAME; N : C.int) `\
`        Import => True,`\
`        Convention => C,`\
`        External_Name => "ofn_set_filter_index";`\
`      `\
`      `` Get_File (X : OPENFILENAME) `` System.Address;`\
`      `` Import (C, Get_File, "ofn_get_file");`\
`      `\
`      `` Get_File_Length (X : OPENFILENAME) `` C.size_t;`\
`      `` Import (C, Get_File_Length, "ofn_get_file_length");`\
`      `\
`      `` Free (X : OPENFILENAME) `\
`        Import => True,`\
`        Convention => C,`\
`        External_Name => "ofn_free";`\
`      `\
`      OFN : OPENFILENAME;`\
`      Ret : C.int;`\
`      File : `` C.char_array := "test.txt" & C.nul;`\
`      Filter : `` C.char_array := "All" & C.nul & "*.*" & C.nul & C.nul & C.nul;`\
`   `\
`      OFN := Allocate;`\
`      Set_Struct_Size (OFN);`\
`      Set_Owner (OFN, Window_Type (System.Null_Address));`\
`      Set_File (OFN, File, 256);`\
`      Set_Filter (OFN, Filter);`\
`      Set_Filter_Index (OFN, 0);`\
`      Ret := GetOpenFileName (OFN);`\
`      `` Ret = 0 `\
`         Free (OFN);`\
`         Ada.Text_IO.Put_Line ("No file selected.");`\
`         return;`\
`      `` ``;`\
`      `\
`         Selected_File_Address : System.Address := Get_File (OFN);`\
`         Selected_File_Length : C.size_t := Get_File_Length (OFN);`\
`         Selected_File : char_array (1 .. Selected_File_Length + 1);`\
`         `` Selected_File'Address `` Selected_File_Address;`\
`      `\
`         Ada.Text_IO.Put_Line (To_Ada (Selected_File, Trim_Nul => True));`\
`      ``;`\
`      Free (OFN);`\
`   `` W32_Open_File_Dialog;`\
\
`   W32_Open_File_Dialog;`\
` Main;`

``` c
#include <windows.h>
#include <stdlib.h>

OPENFILENAME *ofn_allocate()
{
    OPENFILENAME *ofn;
    ofn = (OPENFILENAME *) malloc(sizeof(OPENFILENAME));
    if (ofn == NULL)
        return NULL;
    memset(ofn, 0, sizeof(OPENFILENAME));
    return ofn;
}

void ofn_set_struct_size(OPENFILENAME *ofn)
{
    ofn->lStructSize = sizeof(OPENFILENAME);
}

void ofn_set_owner(OPENFILENAME *ofn, void *owner)
{
    ofn->hwndOwner = (HWND) owner;
}

void ofn_set_file(OPENFILENAME *ofn, char *file, int length)
{
    if (ofn->lpstrFile)
        free(ofn->lpstrFile);
    ofn->lpstrFile = (char *)malloc (length);
    if (ofn->lpstrFile == NULL) {
        ofn->nMaxFile = 0;
        return;
    }
    strncpy(ofn->lpstrFile, file, length);
    ofn->nMaxFile = length;
}

void ofn_set_filter(OPENFILENAME *ofn, char *filter)
{
    ofn->lpstrFilter = filter;
}

void ofn_set_filter_index(OPENFILENAME *ofn, int n)
{
    ofn->nFilterIndex = n;
}

void ofn_free(OPENFILENAME *ofn)
{
    if (ofn->lpstrFile)
        free(ofn->lpstrFile);
    free(ofn);
}

int ada_getopenfilename(OPENFILENAME *ofn)
{
    return (int) GetOpenFileNameA(ofn);
}

char *ofn_get_file(OPENFILENAME *ofn)
{
    return ofn->lpstrFile;
}

size_t ofn_get_file_length(OPENFILENAME *ofn)
{
    return (size_t) lstrlen (ofn->lpstrFile);
}
```

The following project file (getopenfilename.gpr) shows how to link to
comdlg32.dll:

    project Getopenfilename is
       for Languages use ("Ada", "C");
       for Source_Dirs use ("src");
       for Object_Dir use "obj";
       for Main use ("main.adb");

       package Linker is
          for Default_Switches ("ada") use ("-lComdlg32");
       end Linker;
    end Getopenfilename;

## Hardware devices

Embedded programmers usually have to write device drivers. Ada provides
extensive support for interfacing with hardware, like using
representation
clauses to specify
the exact representation of types used by the hardware, or standard
interrupt handling for writing Interrupt service
routines.

## See also

### Wikibook

-   Ada Programming
-   Ada
    Programming/Libraries/Interfaces

### Ada Reference Manual

-
-
### Ada 95 Rationale

-
### Ada Quality and Style Guide

-
Programming}}\|Interfacing Ada
Programming}}/Unfinished module\|Interfacing


# Ada Programming/Coding standards

## Introduction

Each project should follow a specific coding
standard to ease readability and
maintenance of the source code, and reduce the insertion of errors.
Depending on the requirements of the project, a set of guidelines can
help to achieve the desired level of performance, portability, code
complexity\...

There are many ASIS
tools that can be used to check automatically the adherence of Ada
source code to the guidelines.

## Tools

-   AdaControl
    (Rules)
-   gnatcheck
-   GNAT
    Pretty-Printer
-   The GNAT Metric Tool
    gnatmetric

## Coding guidelines

-   *Ada Quality & Style Guide: Guidelines
    for Professional Programmers*

-   ISO/IEC TR 15942:2000, *Guide for the use of the Ada programming
    language in high integrity
    systems.zip)*,
    First edition (2000-03-01). ISO Freely Available
    Standards

-
-
-       (PDF)

## See also

### Other wikibooks

-   Ada Style Guide

### Wikibook

-   Ada Programming

### Ada Quality and Style Guide

-
## External links

-   Introduction to Coding
    Standards

Programming}}\|Coding standards


# Ada Programming/Tips

## Full declaration of a type can be deferred to the unit\'s body

Often, you\'ll want to make changes to the internals of a private type.
This, in turn, will require the algorithms that act on it to be
modified. If the type is completed in the unit specification, it is a
pain to edit and recompile both files, even with an
IDE, but
it\'s something some programmers learn to live with.

It turns out you don\'t have to. Nonchalantly mentioned in the
ARM, and
generally skipped over in tutorials, is the fact that private types can
be completed in the unit\'s body itself, making them much closer to the
relevant code, and saving a recompile of the specification, as well as
every unit depending on it. This may seem like a small thing, and, for
small projects, it is. However, if you have one of those uncooperative
types that requires dozens of tweaks, or if your dependence graph has
much depth, the time and annoyance saved add up quickly.

Also, this construction is very useful when coding a shared library,
because it permits to change the implementation of the type while still
providing a compatible ABI.

Code sample:

` Private_And_Body `\
\
`  `` Private_Type `` `` ``;`\
\
`  `\
\
\
`  `` Body_Type;   `\
`  `` Private_Type `` `` Body_Type;`\
` Private_And_Body;`

The type in the public part is an
access to the hidden type.
This has the drawback that memory management has to be provided by the
package implementation. That is the reason why `Private_Type` is a
limited type, the client will not be allowed to copy the access values,
in order to prevent dangling references.

Normally, the full type definition has to be given in the specification
because the compiler has to know how much place to allocate to objects
in order to produce code using this type. And the astute reader will
note that also in this case the full type definition is given for
Private_Type: it is an access to some other (albeit incomplete) type,
and the size of an access value is known. This is why the full type
definition of Body_Type can be moved to the body.

The construction centering around `Private_Type` is sometimes called an
opaque pointer.

## Lambda calculus through generics

Suppose you\'ve decided to roll your own
set "wikilink") type. You can add
things to it, remove things from it, and you want to let a user apply
some arbitrary function to all of its members. But the scoping rules
seem to conspire against you, forcing nearly everything to be global.

The mental stumbling block is that most examples given of
generics are packages, and the Set package is
already generic. In this case, the solution is to make the Apply_To_All
procedure generic as well; that is, to nest the generics. Generic
procedures inside packages exist in a strange scoping limbo, where
anything in scope at the instantiation can be used by the instantiation,
and anything normally in scope at the formal can be accessed by the
formal. The end result is that the relevant scoping roadblocks no longer
apply. It isn\'t the full lambda calculus, just one of the most useful
parts.

\
`  `` Element `` ``;`\
` Sets `\
`  `` Set `` ``;`\
`   `*`[..]`*\
`  `\
`    `` `` Apply_To_One (The_Element : `` `` Element);`\
`  `` Apply_To_All (The_Set : `` `` Set);`\
` Sets;`

For a view of Functional Programming in Ada see.[^1]

## Compiler Messages

Different compilers can diagnose different things differently, or the
same thing using different messages, etc.. Having two compilers at hand
can be useful.

`selected component`: When a source program contains a construct such as `Foo.Bar`, you may see messages saying something like «selected component \"Bar\"» or maybe like «selected component \"Foo\"». The phrases may seem confusing, because one refers to `Foo`, while the other refers to `Bar`. But they are both right. The reason is that `selected_component` is an item from Ada\'s grammar (). It denotes all of: a prefix, a dot, and a selector_name. In the `Foo.Bar` example these correspond to `Foo`, \'`.`\', and `Bar`. Look for more grammar words in the compiler messages, e.g. «prefix», and associate them with identifiers quoted in the messages.

```{=html}
<!-- -->
```

:   For example, if you submit the following code to the compiler,

` `*`Pak`*\
` Foo `\
`   `` T `` `` `*`Pak`*`Bar``  `\
` Foo`

:   the compiler may print a diagnostic message about a prefixed
    component: `Foo`\'s author thought that `Pak` denotes a package, but
    actually it is the name of a *generic* package. (Which needs to be
    instantiated first; and then the *instance* name is a suitable
    prefix.)

## Universal integers

All integer literals and also some attributes like `'Length` are of the
anonymous type *universal_integer*, which comprises the infinite set of
mathematical integers. Named numbers are of this type and are evaluated
exactly (no overflow except for machine storage limitations), e.g.

` Very_Big: `` := 10**1_000_000 - 1;`

Since *universal_integer* has no operators, its values are converted in
this example to *root_integer*, another anonymous type, the calcuation
is performed and the result again converted back in *universal_integer*.

Generally values of *universal_integer* are implicitly converted to the
appropriate type when used in some expression. So the expression
` A`
is fine; the value of
`A`
is interpreted as a modular integer since
 can only be applied to modular
integers (of course a context is needed to decide which modular integer
type is meant). This feature can lead to pitfalls. Consider

`   `` Ran_6 `` `` 1 `` 6`\
`   `` Mod_6 `` `` 6`

and then

`   `\
`   `` A`` `` Ran_6 ``  `\
`      …`\
\
`   `\
`   `` `` A`` `` Ran_6 ``  `\
`      …`\
`   `\
`   `` (`` A``) `` Ran_6 ``  `\
`      …`\
\
`   `\
`   `` A`` `` 1 `` 6 ``  `\
`      …`\
\
`   `\
`   `` `` A`` `` 1 `` 6 ``  `\
`      …`\
\
`   `\
`   `` A`` `` Mod_6 ``  `\
`      …`\
\
`   `\
`   `` `` A`` `` Mod_6 ``  `\
`      …`

:   The second conditional cannot be compiled because the expressions to
    the left of  is incompatible to the
    type at the right. Note that  has
    precedence over . It does not negate
    the entire membership test but only
    `A`.

```{=html}
<!-- -->
```

:   The fourth conditional fails in various ways.

```{=html}
<!-- -->
```

:   The sixth conditional might be fine because
     turns
    `A`
    into a modular value which is OK if the value is covered by modular
    type `Mod_6`.

```{=html}
<!-- -->
```

:   GNAT GPL 2009 gives these diagnoses respectively:

`error: incompatible types`\
`error: operand of not must be enclosed in parentheses`\
`warning: not expression should be parenthesized here`

:   A way to *avoid* these problems is to use
    ` `
    for the membership test (which, btw., is the language-intended
    form),

`   `` A`` `` `` Ran_6 ``  `\
`      …`

:   See
    -           ,

    -           ), and

    -           ,

    -           ,

    -   Membership
        Tests

## I/O

### Text_IO Issues

A canonical method of reading a sequence of lines from a text file uses
the standard procedure
.*Get_Line*. When the end of
input is reached, *Get_Line* will fail, and exception *End_Error* is
raised. Some programs will use another function from
 to prevent this and test for
*End_of_File*. However, this isn\'t always the best choice, as has been
explained for example in a Get_Line news group discussion on
comp.lang.ada.

A working solution uses an exception handler instead:

`  `\
`     The_Line`` String``1``100`\
`     Last`` Natural`\
`  `\
`     `\
`        Text_IO``Get_Line``The_Line`` Last`\
`        `\
`     `` `\
`  `\
`     `` Text_IO``End_Error `\
`        `\
`  `

The function End_of_File RM A.10.1(34) works fine as long as the file
follows the canonical form of text files presumed by Ada, which is
always the case when the file has been written by
. This canonical form requires
an End_of_Line marker followed by an End_of_Page marker at the very end
before the End_of_File.

If the file was produced by another any other means, it will generally
not have this canonical form, so a test for End_of_File will fail.
That\'s why the exception End_Error has to be used in those cases (which
always works).

## Quirks

Using GNAT on Windows, calls to subprograms from
 might need special
attention. (For example, the `Real_Time.Clock` function might seem to
return values indicating that no time has passed between two invocations
when certainly some time has passed.) The cause is reported to be a
missing initialization of the run-time support when no other real-time
features are present in the program.[^2] As a provisional fix, it is
suggested to insert

` 0``0`

before any use of `Real_Time` services.

### Stack Size

With some implementations, notably GNAT, knowledge of stack size
manipulation will be to your advantage. Executables produced with GNAT
tools and standard settings can hit the stack size limit. If so, the
operating system might allow setting higher limits. Using GNU/Linux and
the Bash command shell, try

`$ ulimit -s [some number]`

The current value is printed when only `-s` is given to *ulimit*.

## References

```{=html}
<references/>
```
## See also

### Wikibook

-   Ada Programming
-   Ada Programming/Errors

### Ada Reference Manual

-

[^1]: Functional Programming
    in\...Ada?,
    by Chris Okasaki

[^2]:
        Usenet article forwards this information from AdaCore.


# Ada Programming/Errors

Some language features are often misunderstood, resulting in common
programming errors, performance degradation and portability problems.
The following incorrect usages of the Ada language are often seen in
code written by Ada beginners.

## pragma Atomic & Volatile

## pragma Pack

## \'Bit_Order attribute

## \'Size attribute

## See also

### Wikibook

-   Ada Programming
-   Ada Programming/Tips

## References

```{=html}
<references/>
```
Programming}}\|Errors Ada
Programming}}/Common errors


# Ada Programming/Error handling

## Error handling techniques

This chapter describes various error handling techniques. First the
technique is described, then its use is shown with an example function
and a call to that function. We use the √ function which should report
an error condition when called with a negative parameter.

To be specific: Exceptions is the Ada way to go.

### Return code

` Error_Handling_1 `\
\
`  `` Square_Root (X : `` Float) `` Float `\
`     `` Ada.Numerics.Elementary_Functions;`\
`  `\
`     `` X < 0.0 `\
`        `` -1.0;`\
`     `\
`        `` Sqrt (X);`\
`     `` ``;`\
`  `` Square_Root;`\
\
\
\
`  C := Square_Root (A ** 2 + B ** 2);`\
\
`  `` C < 0.0 `\
`     T_IO.Put ("C cannot be calculated!");`\
`  `\
`     T_IO.Put ("C is ");`\
`     F_IO.Put`\
`       (Item => C,`\
`        Fore => F_IO.Default_Fore,`\
`        Aft  => F_IO.Default_Aft,`\
`        Exp  => F_IO.Default_Exp);`\
`  `` ``;`\
\
` Error_Handling_1;`

Our example makes use of the fact that all valid return values for √ are
positive and therefore -1 can be used as an error indicator. However
this technique won\'t work when all possible return values are valid and
no return value is available as error indicator; hence to use this
method is a very bad idea.

### Error (success) indicator parameter

An error condition is returned via additional *out* parameter.
Traditionally the indicator is either a boolean with \"true = success\"
or an enumeration with the first element being \"Ok\" and other elements
indicating various error conditions.

` Error_Handling_2 `\
\
` `` Square_Root`\
`    (Y       : `` Float;`\
`     X       : ``  Float;`\
`     Success : `` Boolean)`\
`  `\
`     `` Ada.Numerics.Elementary_Functions;`\
`  `\
`     `` X < 0.0 `\
`        Y       := 0.0;`\
`        Success := False;`\
`     `\
`        Y       := Sqrt (X);`\
`        Success := True;`\
`     `` ``;`\
`     ``;`\
`  `` Square_Root;`\
\
\
\
`  Square_Root`\
`    (Y       => C,`\
`     X       => A ** 2 + B ** 2,`\
`     Success => Success);`\
\
`  `` Success `\
`     T_IO.Put ("C is ");`\
`     F_IO.Put (Item => C);`\
`  `\
`     T_IO.Put ("C cannot be calculated!");`\
`  `` ``;`\
\
` Error_Handling_2;`

One restriction for Ada up to Ada 2005 is that functions cannot have out
parameters. (Functions can have any side effects but may not show them).
So for our example we had to use a procedure instead. The bad news is
that the Success parameter value can easily be ignored.

In Ada 2012, functions may have parameters of any mode; hence this is
possible at last:

` `` Square_Root`\
`    (X       : ``  Float;`\
`     Success : `` Boolean) `` Float`\
`  `\
`    ...`

This technique does not look very nice in mathematical calculations;
hence no good idea either.

### Global variable

An error condition is stored inside a global variable. This variable is
then read directly or indirectly via a function.

` Error_Handling_3 `\
\
`  Float_Error : Boolean;`\
\
`  `` Square_Root (X : `` Float) `` Float`\
`  `\
`     `` Ada.Numerics.Elementary_Functions;`\
`  `\
`     `` X < 0.0 `\
`        Float_Error := True;`\
`        `` 0.0;`\
`     `\
`        `` Sqrt (X);`\
`     `` ``;`\
`  `` Square_Root;`\
\
\
\
`  Float_Error := False;  -- reset the indicator before use`\
`  C := Square_Root (A ** 2 + B ** 2);`\
\
`  `` Float_Error `\
`     T_IO.Put ("C cannot be calculated!");`\
`  `\
`     T_IO.Put ("C is ");`\
`     F_IO.Put`\
`       (Item => C,`\
`        Fore => F_IO.Default_Fore,`\
`        Aft  => F_IO.Default_Aft,`\
`        Exp  => F_IO.Default_Exp);`\
`  `` ``;`\
\
` Error_Handling_3;`

As you can see from the source, the problematic part of this technique
is choosing the place at which the flag is reset. You could either have
the callee or the caller do that.

Also this technique is not suitable for multithreading.

Use of global variables for cases like this indeed is a very bad idea,
in effect one of the worst.

### Exceptions

Ada supports a form of error handling that has long been used by other
languages like the classic `ON ERROR GOTO ...` from early Basic dialects
to the `try ... catch` exception handling from modern object oriented
languages.

The idea is: You register some part of your program as error handler to
be called whenever an error happens. You can even define more than one
handler to handle different kinds of errors separately. Once an error
occurs, the execution jumps to the error handler and continues there; it
is impossible to return to the location where the error occurred.

This is the Ada way!

` Error_Handling_4 `\
\
`  Root_Error: ``;`\
\
`  `` Square_Root (X : `` Float) `` Float `\
`     `` Ada.Numerics.Elementary_Functions;`\
`  `\
`     `` X < 0.0 `\
`        `` Root_Error;`\
`     `\
`        `` Sqrt (X);`\
`     `` ``;`\
`  `` Square_Root;`\
\
\
\
`   C := Square_Root (A ** 2 + B ** 2);`\
\
`   T_IO.Put ("C is ");`\
`   F_IO.Put`\
`       (Item => C,`\
`        Fore => F_IO.Default_Fore,`\
`        Aft  => F_IO.Default_Aft,`\
`        Exp  => F_IO.Default_Exp);`\
\
`   `` Root_Error =>`\
`      T_IO.Put ("C cannot be calculated!");`\
\
` Error_Handling_4;`

The great strength of exceptions handling is that it can block several
operations within one exception handler. This eases the burden of error
handling since not every function or procedure call needs to be checked
independently for successful execution.

### Design by contract

In Design by Contract (DbC), operations must be called with the correct
parameters. This is the caller\'s part of the contract. If the subtypes
of the actual arguments match the subtypes of the formal arguments, and
if the actual arguments have values that make the function\'s
preconditions True, then the subprogram gets a chance to fulfill its
postcondition. Otherwise an error condition occurs.

Now you might wonder how that is going to work. Let\'s look at the
example first:

` Error_Handling_5 `\
\
`  `` Square_Root_Type `` Float `` 0.0 .. Float'``;`\
` `\
`  `` Square_Root`\
`    (X    : `` Square_Root_Type)`\
`     `` Square_Root_Type`\
`  `\
`     `` Ada.Numerics.Elementary_Functions;`\
`  `\
`     `` Sqrt (X);`\
`  `` Square_Root;`\
\
\
\
`  C := Square_Root (A ** 2 + B ** 2);`\
\
`  T_IO.Put ("C is ");`\
`  F_IO.Put`\
`    (Item => C,`\
`     Fore => F_IO.Default_Fore,`\
`     Aft  => F_IO.Default_Aft,`\
`     Exp  => F_IO.Default_Exp);`\
\
`  ``;`\
` Error_Handling_5;`

As you can see, the function requires a precondition of `X >= 0` ---
that is, the function can only be called when
`<var>`{=html}X`</var>`{=html} ≥ 0. In return the function promises as
postcondition that the return value is also ≥ 0.

In a full DbC approach, the postcondition will state a relation that
fully describes the value that results when running the function,
something like `result ≥ 0 and X = result * result`. This postcondition
is √\'s part of the contract. The use of assertions, annotations, or a
language\'s type system for expressing the precondition `X >= 0`
exhibits two important aspects of Design by Contract:

1.  There can be ways for the compiler, or analysis tool, to help check
    the contracts. (Here for example, this is the case when `X ≥ 0`
    follows from X\'s subtype, and √\'s argument when called is of the
    same subtype, hence also ≥ 0.)
2.  The precondition can be mechanically checked **before** the function
    is called.

The 1st aspect adds to safety: No programmer is perfect. Each part of
the contract that needs to be checked by the programmers themselves has
a high probability for mistakes.

The 2nd aspect is important for optimization --- when the contract can
be checked at compile time, no runtime check is needed. You might not
have noticed but if you think about it: $A^2 + B^2$ is never negative,
*provided* the exponentiation operator and the addition operator work in
the usual way.

We have made 5 nice error handling examples for a piece of code which
never fails. And this is the great opportunity for controlling some
runtime aspects of DbC: You can now safely turn checks off, and the code
optimizer can omit the actual range checks.

DbC languages distinguish themselves on how they act in the face of a
contract breach:

1.  True DbC programming languages combine DbC with exception handling
    --- raising an exception when a contract breach is detected at
    runtime, and providing the means to restart the failing routine or
    block in a known good state.
2.  Static analysis tools check all contracts at analysis time and
    demand that the code written in such a way that no contract can ever
    be breached at runtime.

Ada 2012 has introduced pre- and postcondition aspects.

## See also

### Wikibook

-   Ada Programming
-   Ada Programming/Exceptions

### Ada 95 Reference Manual

-
-
### Ada 2005 Reference Manual

-
-


# Ada Programming/Function overloading

## Description

***Function overloading*** (also *method overloading*) is a programming
concept that allows programmers to define two or more functions with the
same name and in the same scope.

Each function has a unique signature (or header), which is derived from:

1.  function/procedure name
2.  number of arguments
3.  arguments\' type
4.  arguments\' order
5.  arguments\' name
6.  return type

Please note: Not all above signature options are available in all
programming languages.

  Language   1     2     3     4     5     6
  ---------- ----- ----- ----- ----- ----- -----
  Ada        yes   yes   yes   yes   yes   yes
  C++        yes   yes   yes   yes   no    no
  Java       yes   yes   yes   yes   no    no
  Swift      yes   yes   yes   yes   yes   yes

  : Available functions overloadings

Warning: Function overloading is often confused with function
overriding. In Function overloading, a function with a different
signature is created, adding to the pool of available functions. In
function overriding, however, a function with the same signature is
declared, replacing the old function in the context of the new function.

## Demonstration

Since functions\' names are in this case the same, we must preserve
uniqueness of signatures, by changing something from the ***parameter
list*** (last three alienees).

If the functions\' signatures are sufficiently different, the compiler
can distinguish which function was intended to be used at each
occurrence. This process of searching for the appropriate function is
called ***function resolution*** and can be quite an intensive one,
especially if there are a lot of equally named functions.

Programming languages supporting implicit type conventions usually use
promotion of arguments (i.e. type casting of integer to floating-point)
when there is no exact function match. The demotion of arguments is
rarely used.

When two or more functions match the criteria in function resolution
process, an ***ambiguity error*** is reported by compiler. Adding more
information for the compiler by editing the source code (using for
example type casting), can address such doubts.

The example code shows how function overloading can be used. As
functions do practically the same thing, it makes sense to use function
overloading.

\
\
` Generate_Number (MaxValue : Integer) `` Integer `\
`   `` Random_Type `` Integer `` 0 .. MaxValue;`\
`   `` Random_Pack `` `` `` (Random_Type);`\
` `\
`   G : Random_Pack.Generator;`\
\
`   Random_Pack.Reset (G);`\
`   `` Random_Pack.Random (G);`\
` Generate_Number;`\
\
\
` Generate_Number (MinValue : Integer;`\
`                          MaxValue : Integer) `` Integer`\
\
`   `` Random_Type `` Integer `` MinValue .. MaxValue;`\
`   `` Random_Pack `` `` `` (Random_Type);`\
` `\
`   G : Random_Pack.Generator;`\
\
`   Random_Pack.Reset (G);`\
`   `` Random_Pack.Random (G);`\
` Generate_Number;`

### calling the first function

The first code block will generate numbers from 0 up to specified
parameter *MaxValue*. The appropriate function call is:

` Number_1 : Integer := Generate_Number (10);`

### calling the second function

The second requires another parameter *MinValue*. Function will return
numbers above or equals *MinValue* and lower than *MaxValue*.

` Number_2 : Integer := Generate_Number (6, 10);`

## Function overloading in Ada

Ada supports all six signature options, but if you use the arguments\'
name as option, you will always have to name the parameter when calling
the function. i.e.:

`Number_2 : Integer := Generate_Number (MinValue => 6,`\
`                                       MaxValue => 10);`

Note that you cannot overload a generic procedure or generic function
within the same package. The following example will fail to compile:

` `` myPackage`\
`   `\
`     `` Value_Type `` (<>);  `\
`   `\
`   `\
`   `` Generic_Subprogram (Value : `` `` Value_Type);`\
`   ...`\
`   `\
`     `` Value_Type `` (<>); `\
`   `\
`   `\
`   `\
`   `\
`   `\
`   `` Generic_Subprogram;`\
`   ...`\
`   `\
`     `` Value_Type `` (<>); `\
`   `\
`   `\
`   `\
`   `\
`   `` Generic_Subprogram (Value : Value_Type) `` Value_Type;`\
` `` myPackage;`

## See also

### Wikibook

-   Ada Programming
-   Ada
    Programming/Subprograms

### Ada 95 Reference Manual

-
-
### Ada 2005 Reference Manual

-
-


# Ada Programming/Mathematical calculations

Ada is very well suited for all kinds of calculations. You can define
your own fixed point and floating point types and --- with the aid of
generic packages call all the mathematical functions you need. In that
respect Ada is on par with Fortran.
This module will show you how to use them and while we progress we
create a simple RPN
calculator.

## Simple calculations

### Addition

Additions can be done using the predefined operator
. The operator is predefined for all
numeric types and the following, working code, demonstrates its use:

\
\
`{{Ada/--|{{Ada/95/RM|A|10|1|title=The Package Text_IO}}}}`{=mediawiki}\
` ``;`\
\
` Numeric_1 `\
`   `` Value_Type `` `` 12`\
`         `` -999_999_999_999.0e999 .. 999_999_999_999.0e999;`\
\
`   `` T_IO `` Ada.Text_IO;`\
`   `` F_IO `` ``  Ada.Text_IO.Float_IO (Value_Type);`\
\
`   Value_1 : Value_Type;`\
`   Value_2 : Value_Type;`\
\
\
`   T_IO.Put ("First Value : ");`\
`   F_IO.Get (Value_1);`\
`   T_IO.Put ("Second Value : ");`\
`   F_IO.Get (Value_2);`\
\
`   F_IO.Put (Value_1);`\
`   T_IO.Put (" + ");`\
`   F_IO.Put (Value_2);`\
`   T_IO.Put (" = ");`\
`   F_IO.Put (Value_1 `` Value_2);`\
` Numeric_1;`

### Subtraction

Subtractions can be done using the predefined operator
. The following extended demo shows the
use of + and - operator together:

\
\
`{{Ada/--|{{Ada/95/RM|A|10|1|title=The Package Text_IO}}}}`{=mediawiki}\
` `\
\
` Numeric_2`\
\
`  `` Value_Type`\
`  `` `\
`     12`\
`  `\
`     -999_999_999_999.0e999 .. 999_999_999_999.0e999;`\
\
`  `` T_IO `` ``;`\
`  `` F_IO `` ``  Ada.Text_IO.Float_IO (Value_Type);`\
\
`  Value_1   : Value_Type;`\
`  Value_2   : Value_Type;`\
`  Result    : Value_Type;`\
`  Operation : Character;`\
\
\
`  T_IO.Put ("First Value  : ");`\
`  F_IO.Get (Value_1);`\
`  T_IO.Put ("Second Value : ");`\
`  F_IO.Get (Value_2);`\
`  T_IO.Put ("Operation    : ");`\
`  T_IO.Get (Operation);`\
\
`  `` Operation `\
`     `` '+' =>`\
`        Result := Value_1 + Value_2;`\
`     `` '-' =>`\
`        Result := Value_1 - Value_2;`\
`     `` `` =>`\
`        T_IO.Put_Line ("Illegal Operation.");`\
`        `` Exit_Numeric_2;`\
`  `` ``;`\
\
`  F_IO.Put (Value_1);`\
`  T_IO.Put (" ");`\
`  T_IO.Put (Operation);`\
`  T_IO.Put (" ");`\
`  F_IO.Put (Value_2);`\
`  T_IO.Put (" = ");`\
`  F_IO.Put (Result);`\
\
`Exit_Numeric_2`\
`  ``;`\
\
` Numeric_2;`

Purists might be surprised about the use of goto --- but some people
prefer the use of goto over the use of multiple return statements if
inside functions --- given that, the opinions on this topic vary
strongly. See the isn\'t goto
evil article.

### Multiplication

Multiplication can be done using the predefined operator
. For a demo see the next chapter about
Division.

### Division "wikilink")

Divisions can be done using the predefined operators
, ,
. The operator
 performs a normal division,
 returns a modulus division and
 returns the remainder of the modulus
division.

The following extended demo shows the use of the
, ,
 and
operators together as well as the use of a four number wide stack to
store intermediate results:

The operators  and
 are not part of the demonstration as
they are only defined for integer types.

\
\
` ``;`\
\
` Numeric_3 `\
`   `` Pop_Value;`\
`   `` Push_Value;`\
\
`   `` Value_Type `` `` 12 `\
`     -999_999_999_999.0e999 .. 999_999_999_999.0e999;`\
\
`   `` Value_Array `` `` (Natural `` 1 .. 4) `` Value_Type;`\
\
`   `` T_IO `` Ada.Text_IO;`\
`   `` F_IO `` `` Ada.Text_IO.Float_IO (Value_Type);`\
\
`   Values    : Value_Array := (`` => 0.0);`\
`   Operation : String (1 .. 40);`\
`   Last      : Natural;`\
\
`   `` Pop_Value `\
`   `\
`      Values (Values'`` + 1 .. Values'``) :=`\
`        Values (Values'`` + 2 .. Values'``) & 0.0;`\
`   `` Pop_Value;`\
\
`   `` Push_Value `\
`   `\
`      Values (Values'`` + 1 .. Values'``) :=`\
`        Values (Values'`` .. Values'`` - 1);`\
`   `` Push_Value;`\
\
\
`   Main_Loop:`\
`   `\
`      T_IO.Put (">");`\
`      T_IO.Get_Line (Operation, Last);`\
\
`      `` Last = 1 `` `` Operation (1) = '+' `\
`         Values (1) := Values (1) + Values (2);`\
`         Pop_Value;`\
`      `` Last = 1 `` `` Operation (1) = '-' `\
`         Values (1) := Values (1) + Values (2);`\
`         Pop_Value;`\
`      `` Last = 1 `` `` Operation (1) = '*' `\
`         Values (1) := Values (1) * Values (2);`\
`         Pop_Value;`\
`      `` Last = 1 `` `` Operation (1) = '/' `\
`         Values (1) := Values (1) / Values (2);`\
`         Pop_Value;`\
`      `` Last = 4 `` `` Operation (1 .. 4) = "exit" `\
`         `` Main_Loop;`\
`      `\
`         Push_Value;`\
`         F_IO.Get (From => Operation, Item => Values (1), Last => Last);`\
`      `` ``;`\
`      `\
`      Display_Loop:`\
`      `` I `` `` Value_Array'`` `\
`         F_IO.Put`\
`           (Item => Values (I),`\
`            Fore => F_IO.Default_Fore,`\
`            Aft  => F_IO.Default_Aft,`\
`            Exp  => 4);`\
`         T_IO.New_Line;`\
`      `` `` Display_Loop;`\
`   `` `` Main_Loop;`\
\
`   ``;`\
` Numeric_3;`

## Exponential calculations

All exponential functions are defined inside the generic package
.

### Power of

Calculation of the form $x^y$ are performed by the operator
. Beware: There are two versions of
this operator. The predefined operator
allows only for Standard.Integer to be used as exponent. If you need to
use a floating point type as exponent you need to use the
 defined in
.

### Root "wikilink")

The square root $\sqrt{x}$ is calculated with the function `Sqrt()`.
There is no function defined to calculate an arbitrary root
$\sqrt[n]{x}$. However you can use logarithms to calculate an arbitrary
root using the mathematical identity: $\sqrt[b]{a} = e^{\log_e (a) / b}$
which will become `root := Exp (Log (a) / b)` in Ada. Alternatively, use
$\sqrt[b]{a}=a^{\frac1b}$ which, in Ada, is `root := a**(1.0/b)`.

### Logarithm

defines a function for both the arbitrary logarithm $log_n(x)$ and the
natural logarithm $log_e(x)$, both of which have the same name `Log()`
distinguished by the number of parameters.

### Demonstration

The following extended demo shows the how to use the exponential
functions in Ada. The new demo also uses
Unbounded_String
instead of Strings which make the comparisons easier.

Please note that from now on we won\'t copy the full sources any more.
Do follow the download links to see the full program.

\
\
` ``;`\
` ``;`\
` ``;`\
\
` Numeric_4 `\
`  `` Str `` Ada.Strings.Unbounded;`\
`  `` T_IO `` Ada.Text_IO;`\
\
`  `` Pop_Value;`\
`  `` Push_Value;`\
`  `` Get_Line `` Str.Unbounded_String;`\
\
`  `` Value_Type `` `` 12 `\
`     -999_999_999_999.0e999 .. 999_999_999_999.0e999;`\
\
`  `` Value_Array `` `` (Natural `` 1 .. 4) `` Value_Type;`\
\
`  `` F_IO `` `` Ada.Text_IO.Float_IO (Value_Type);`\
`  `` Value_Functions `` `` Ada.Numerics.Generic_Elementary_Functions (`\
`     Value_Type);`\
\
`  `` Value_Functions;`\
`  `` `` Str.Unbounded_String;`\
\
`  Values    : Value_Array := (`` => 0.0);`\
`  Operation : Str.Unbounded_String;`\
`  Dummy     : Natural;`\
\
`  `` Get_Line `` Str.Unbounded_String `\
`     BufferSize : `` := 2000;`\
`     Retval     : Str.Unbounded_String := Str.Null_Unbounded_String;`\
`     Item       : String (1 .. BufferSize);`\
`     Last       : Natural;`\
`  `\
`     Get_Whole_Line :`\
`        `\
`           T_IO.Get_Line (Item => Item, Last => Last);`\
\
`           Str.Append (Source => Retval, New_Item => Item (1 .. Last));`\
\
`           `` Get_Whole_Line `` Last < Item'``;`\
`        `` `` Get_Whole_Line;`\
\
`     `` Retval;`\
`  `` Get_Line;`\
\
`...`\
\
\
`  Main_Loop :`\
`     `\
`        T_IO.Put (">");`\
`        Operation := Get_Line;`\
\
`...`\
`        `` Operation = "e" `` `\
`           Push_Value;`\
`           Values (1) := Ada.Numerics.e;`\
`        `` Operation = "**" `` `` Operation = "^" `` `\
`           Values (1) := Values (1) ** Values (2);`\
`           Pop_Value;`\
`        `` Operation = "sqr" `` `\
`           Values (1) := Sqrt (Values (1));`\
`        `` Operation = "root" `` `\
`           Values (1) :=`\
`              Exp (Log (Values (2)) / Values (1));`\
`           Pop_Value;`\
`        `` Operation = "ln" `` `\
`           Values (1) := Log (Values (1));`\
`        `` Operation = "log" `` `\
`           Values (1) :=`\
`              Log (Base => Values (1), X => Values (2));`\
`           Pop_Value;`\
`        `` Operation = "``" `\
`           `` Main_Loop;`\
`        `\
`           Push_Value;`\
`           F_IO.Get`\
`             (From => Str.To_String (Operation),`\
`              Item => Values (1),`\
`              Last => Dummy);`\
`        `` ``;`\
\
`...`\
`     `` `` Main_Loop;`\
\
`  ``;`\
` Numeric_4;`

## Higher math

### Trigonometric calculations

The full set of trigonometric functions are
defined inside the generic package
.
All functions are defined for 2π and an arbitrary cycle value (a full
cycle of revolution).

Please note the difference of calling the `Arctan ()` function.

` ``;`\
` ``;`\
` ``;`\
\
` Numeric_5 `\
\
`...`\
\
`  `` Put_Line (Value : `` Value_Type);`\
\
`  `` Value_Functions;`\
`  `` `` Str.Unbounded_String;`\
\
`  Values    : Value_Array := (`` => 0.0);`\
`  Cycle     : Value_Type  := Ada.Numerics.Pi;`\
`  Operation : Str.Unbounded_String;`\
`  Dummy     : Natural;`\
\
`...`\
\
`  `` Put_Line (Value : `` Value_Type) `\
`  `\
`     `` `` Value_Type'`` (Value) >=`\
`        `` Value_Type'`` (10.0 ** F_IO.Default_Aft)`\
`     `\
`        F_IO.Put`\
`          (Item => Value,`\
`           Fore => F_IO.Default_Aft,`\
`           Aft  => F_IO.Default_Aft,`\
`           Exp  => 4);`\
`     `\
`        F_IO.Put`\
`          (Item => Value,`\
`           Fore => F_IO.Default_Aft,`\
`           Aft  => F_IO.Default_Aft,`\
`           Exp  => 0);`\
`     `` ``;`\
`     T_IO.New_Line;`\
\
`     ``;`\
`  `` Put_Line;`\
\
`...`\
\
\
`  Main_Loop :`\
`     `\
`        Display_Loop :`\
`           `` I `` ``  Value_Array'`` `\
`              Put_Line (Values (I));`\
`           `` `` Display_Loop;`\
`        T_IO.Put (">");`\
`        Operation := Get_Line;`\
\
`...`\
`        `` Operation = "deg" `` `\
`           Cycle := 360.0;`\
`        `` Operation = "rad" `` `\
`           Cycle := Ada.Numerics.Pi;`\
`        `` Operation = "grad" `` `\
`           Cycle := 400.0;`\
`        `` Operation = "pi" `` `` Operation = "π" `` `\
`           Push_Value;`\
`           Values (1) := Ada.Numerics.Pi;`\
`        `` Operation = "sin" `` `\
`           Values (1) := Sin (X => Values (1), Cycle => Cycle);`\
`        `` Operation = "cos" `` `\
`           Values (1) := Cos (X => Values (1), Cycle => Cycle);`\
`        `` Operation = "tan" `` `\
`           Values (1) := Tan (X => Values (1), Cycle => Cycle);`\
`        `` Operation = "cot" `` `\
`           Values (1) := Cot (X => Values (1), Cycle => Cycle);`\
`        `` Operation = "asin" `` `\
`           Values (1) := Arcsin (X => Values (1), Cycle => Cycle);`\
`        `` Operation = "acos" `` `\
`           Values (1) := Arccos (X => Values (1), Cycle => Cycle);`\
`        `` Operation = "atan" `` `\
`           Values (1) := Arctan (Y => Values (1), Cycle => Cycle);`\
`        `` Operation = "acot" `` `\
`           Values (1) := Arccot (X => Values (1), Cycle => Cycle);`\
\
`...`\
`     `` `` Main_Loop;`\
\
`  ``;`\
` Numeric_5;`

The Demo also contains an improved numeric output which behaves more
like a normal calculator.

### Hyperbolic calculations

You guessed it: The full set of hyperbolic functions is defined inside
the generic package
.

` ``;`\
` ``;`\
` ``;`\
` ``;`\
\
` Numeric_6 `\
`  `` Str `` Ada.Strings.Unbounded;`\
`  `` T_IO `` Ada.Text_IO;`\
`  `` Exept `` Ada.Exceptions;`\
\
`...`\
\
` `\
`  Main_Loop :`\
`     `\
`        Try :`\
`           `\
`              Display_Loop :`\
`...`\
`              `` Operation = "sinh" `` `\
`                 Values (1) := Sinh (Values (1));`\
`              `` Operation = "cosh" `` `\
`                 Values (1) := Coth (Values (1));`\
`              `` Operation = "tanh" `` `\
`                 Values (1) := Tanh (Values (1));`\
`              `` Operation = "coth" `` `\
`                 Values (1) := Coth (Values (1));`\
`              `` Operation = "asinh" `` `\
`                 Values (1) := Arcsinh (Values (1));`\
`              `` Operation = "acosh" `` `\
`                 Values (1) := Arccosh (Values (1));`\
`              `` Operation = "atanh" `` `\
`                 Values (1) := Arctanh (Values (1));`\
`              `` Operation = "acoth" `` `\
`                 Values (1) := Arccoth (Values (1));`\
`...`\
`           `\
`              `` An_Exception : `` =>`\
`                 T_IO.Put_Line`\
`                   (Exept.Exception_Information (An_Exception));`\
`           `` Try;`\
`     `` `` Main_Loop;`\
\
`  ``;`\
` Numeric_6;`

As added bonus this version supports error handling and therefore won\'t
just crash when an illegal calculation is performed.

### Complex arithmethic

For complex arithmetic Ada
provides the package
. This
package is part of the \"special need Annexes\" which means it is
optional. The open source Ada compiler GNAT implements all \"special
need Annexes\" and therefore has complex arithmetic available.

Since Ada supports user defined operators, all
`<small>`{=html}(,
,
)`</small>`{=html} operators have their
usual meaning as soon as the package
 has
been instantiated `<small>`{=html}( \...

\...)`</small>`{=html} and the type has been made visible
`<small>`{=html}(
 \...)`</small>`{=html}

Ada also provides the packages
 and

which provide similar functionality to their normal counterparts. But
there are some differences:

-       supports only the exponential and trigonometric functions which make
    sense in complex arithmetic.

```{=html}
<!-- -->
```
-       is a child package of  and
    therefore needs its own . Note: the
    `Get ()`
    function is pretty fault tolerant - if you forget the \",\" or the
    \"()\" pair it will still parse the input correctly.

So, with only a very few modifications you can convert your \"normals\"
calculator to a calculator for complex arithmetic:

` Ada.Text_IO.Complex_IO;`\
` Ada.Numerics.Generic_Complex_Types;`\
` Ada.Numerics.Generic_Complex_Elementary_Functions;`\
` Ada.Strings.Unbounded;`\
` Ada.Exceptions; `\
\
` Numeric_7 `\
\
`...`\
` `\
`  `` Complex_Types `` `` Ada.Numerics.Generic_Complex_Types (`\
`     Value_Type);`\
`  `` Complex_Functions `` `\
`     Ada.Numerics.Generic_Complex_Elementary_Functions (`\
`     Complex_Types);`\
`  `` C_IO `` `` Ada.Text_IO.Complex_IO (Complex_Types);`\
\
`  `` Value_Array `\
`     `` (Natural `` 1 .. 4) `` Complex_Types.Complex;`\
\
`  `` Put_Line (Value : `` Complex_Types.Complex);`\
\
`  `` `` Complex_Types.Complex;`\
`  `` `` Str.Unbounded_String;`\
`  `` Complex_Functions;`\
\
`  Values    : Value_Array :=`\
`     (`` => Complex_Types.Complex'(Re => 0.0, Im => 0.0));`\
\
`...`\
` `\
`  `` Put_Line (Value : `` Complex_Types.Complex) `\
`  `\
`     `` (`` Value_Type'`` (Value.Re) >=`\
`         `` Value_Type'`` (10.0 ** C_IO.Default_Aft))`\
`       `` `` (`` Value_Type'`` (Value.Im) >=`\
`                `` Value_Type'`` (10.0 ** C_IO.Default_Aft))`\
`     `\
`        C_IO.Put`\
`          (Item => Value,`\
`           Fore => C_IO.Default_Aft,`\
`           Aft  => C_IO.Default_Aft,`\
`           Exp  => 4);`\
`     `\
`        C_IO.Put`\
`          (Item => Value,`\
`           Fore => C_IO.Default_Aft,`\
`           Aft  => C_IO.Default_Aft,`\
`           Exp  => 0);`\
`     `` ``;`\
`     T_IO.New_Line;`\
\
`     ``;`\
`  `` Put_Line;`\
\
\
\
`...`\
`              `` Operation = "e" `` `\
`                 Push_Value;`\
`                 Values (1) :=`\
`                    Complex_Types.Complex'(Re => Ada.Numerics.e, Im => 0.0);`\
\
`...`\
\
`              `` Operation = "pi" `` `` Operation = "π" `` `\
`                 Push_Value;`\
`                 Values (1) :=`\
`                    Complex_Types.Complex'(Re => Ada.Numerics.Pi, Im => 0.0);`\
`              `` Operation = "sin" `` `\
`                 Values (1) := Sin (Values (1));`\
`              `` Operation = "cos" `` `\
`                 Values (1) := Cot (Values (1));`\
`              `` Operation = "tan" `` `\
`                 Values (1) := Tan (Values (1));`\
`              `` Operation = "cot" `` `\
`                 Values (1) := Cot (Values (1));`\
`              `` Operation = "asin" `` `\
`                 Values (1) := Arcsin (Values (1));`\
`              `` Operation = "acos" `` `\
`                 Values (1) := Arccos (Values (1));`\
`              `` Operation = "atan" `` `\
`                 Values (1) := Arctan (Values (1));`\
`              `` Operation = "acot" `` `\
`                 Values (1) := Arccot (Values (1));`\
\
`...`\
\
`  ``;`\
` Numeric_7;`

### Vector and Matrix Arithmetic

Ada supports vector and
matrix
Arithmetic for both normal real types and complex types. For those, the
generic packages Ada.Numerics.Generic_Real_Arrays and
Ada.Numerics.Generic_Complex_Arrays are used. Both packages offer the
usual set of operations, however there is no I/O package and
understandably, no package for elementary functions.

Since there is no I/O package for vector and matrix I/O creating a demo
is by far more complex --- and hence not ready yet. You can have a look
at the current progress which will be a universal calculator merging all
feature.

Status: Stalled - for a Vector and Matrix stack we need
Indefinite_Vectors --- which are currently not part of GNAT/Pro. Well I
could use the booch components \...

## See also

### Wikibook

-   Ada Programming
-   Ada
    Programming/Delimiters/-
-   Ada Programming/Libraries/Ada.Numerics.Generic Complex
    Types
-   Ada Programming/Libraries/Ada.Numerics.Generic Elementary
    Functions

### Ada 95 Reference Manual

-
-
-
-
-
### Ada 2005 Reference Manual

-
-
-
-
-


# Ada Programming/Lexical elements

## Character set

The character set used in Ada programs is composed of:

-   Upper-case letters: A, \..., Z and lower-case letters: a, \..., z.
-   Digits: 0, \..., 9.
-   Special characters.

Take into account that in Ada 95 the letter range includes accented
characters and other letters used in Western Europe languages, those
belonging to the *ISO Latin-1* character set,
as ç, ñ, ð, etc.

In Ada 2005 the character set has
been extended to the full Unicode set, so the
identifiers and comments can be written in almost any language in the
world.

Ada is a case-insensitive language, i. e. the upper-case set is
equivalent to the lower-case set except in character string literals and
character literals.

## Lexical elements

In Ada we can find the following lexical elements:

-   Identifiers
-   Numeric Literals
-   Character Literals
-   String Literals
-   Delimiters
-   Comments
-   Reserved Words

Example:

`Temperature_In_Room := 25;  `

This line contains 5 lexical elements:

-   The identifier `Temperature_In_Room`.
-   The compound delimiter `:=`.
-   The number `25`.
-   The single delimiter `;`.
-   The comment
    .

### Identifiers

Definition in *BNF*:

`identifier ::= letter { [ underscore ] letter | digit }`\
`letter ::= A | ... | Z | a | ... | z`\
`digit ::= 0 | ... | 9`\
`underscore ::= _`

From this definition we must exclude the keywords that are reserved
words in the language and cannot be used as identifiers.

Examples:

The following words are legal Ada identifiers:

`Time_Of_Day  TimeOfDay  El_Niño_Forecast  Façade  counter ALARM`

The following ones are **NOT** legal Ada identifiers:

`_Time_Of_Day  2nd_turn  Start_  Access  Price_In_$  General__Alarm`

**Exercise**: could you give the reason for not being legal for each one
of them?

### Numbers

The numeric literals are composed of the following characters:

-   digits `0 .. 9`
-   the decimal separator `.`,
-   the exponentiation sign `e` or `E`,
-   the negative sign `-` (in exponents only) and
-   the underscore `_`.

The underscore is used as separator for improving legibility for humans,
but it is ignored by the compiler. You can separate numbers following
any rationale, e.g. decimal integers in groups of three digits, or
binary integers in groups of eight digits.

For example, the real number such as 98.4 can be represented as:
`9.84E1`, `98.4e0`, `984.0e-1` or `0.984E+2`, but not as `984e-1`.

For integer numbers, for example 1900, it could be written as `1900`,
`19E2`, `190e+1` or `1_900E+0`.

A numeric literal could also be expressed in a base different to 10, by
enclosing the number between `#` characters, and preceding it by the
base, which can be a number between 2 and 16. For example, `2#101#` is
101~2~, that is 5~10~; a hexadecimal number with exponent is `16#B#E2`,
that is 11 × 16² = 2,816.

Note that there are no negative literals; e.g. -1 is not a literal,
rather it is the literal 1 preceded by the unary minus operator.

### Character literals

Their type is .Character,
Wide_Character or Wide_Wide_Character. They are delimited by an
apostrophe (\').

Examples:

`'A' 'n' '%'`

### String literals

String literals are of type
.String, Wide_String or
Wide_Wide_String. They are delimited by the quotation mark
(\").

Example:

`"This is a string literal"`

### Delimiters

Single delimiters are one of the following special characters:

`&    '    (    )    *    +    ,    -    .    /    :    ;    <    =    >    `

Compound delimiters are composed of two special characters, and they are
the following ones:

`=>    ..    **    :=    /=    >=    <=    <<    >>    <>`

You can see a full reference of the delimiters in Ada
Programming/Delimiters.

### Comments

Comments in Ada start with two consecutive hyphens (`--`) and end in the
end of line.

\
`My_Savings := My_Savings * 10.0; `\
`My_Savings := My_Savings * `\
`    1_000_000.0;`

A comment can appear where an end of line can be inserted.

### Reserved words

Reserved words are equivalent in upper-case and lower-case letters,
although the typical style is the one from the Reference Manual, that is
to write them in all lower-case letters.

In Ada some keywords have a different meaning depending on context. You
can refer to Ada
Programming/Keywords and the
following pages for each keyword.

## See also

### Wikibook

-   Ada Programming
-   Ada Programming/Delimiters
-   Ada Programming/Keywords

### Ada Reference Manual

-
-
-
elements

es:Programación en Ada/Elementos del
lenguaje


# Ada Programming/Keywords

## Language summary keywords

Most Ada "keywords" have different functions depending on where they are
used. A good example is
**for** which controls the
representation clause when used within a declaration part and controls a
loop when used within an implementation.

In Ada, a keyword is a **reserved word**, so it cannot be used as an
identifier. Some of them are used as
attribute names.

## List of keywords

## See also

### Wikibook

-   Ada Programming
-   Ada Programming/Aspects
-   Ada Programming/Attributes
-   Ada Programming/Pragmas

### Ada Reference Manual

#### Ada 83

-
-
#### Ada 95

-
-
#### Ada 2005

-
-
#### Ada 2012

-
-
### Ada Quality and Style Guide

-
Programming}}\|Keywords Ada
Programming}}/Ada 2005 feature\|Keywords

es:Programación en Ada/Palabras
reservadas


# Ada Programming/Delimiters

## Single character delimiters

& : ampersand `<small>`{=html}(operator)`</small>`{=html}\
\' : apostrophe, tick\
( : left parenthesis\
) "wikilink") : right parenthesis\
\* : asterisk, multiply `<small>`{=html}(operator)`</small>`{=html}\
+ : plus sign `<small>`{=html}(operator)`</small>`{=html}\
, : comma\
- : hyphen, minus `<small>`{=html}(operator)`</small>`{=html}\
. : full stop, point, dot\
/ : solidus, divide `<small>`{=html}(operator)`</small>`{=html}\
: : colon\
; : semicolon\
\< : less than sign `<small>`{=html}(operator)`</small>`{=html}\
= : equal sign `<small>`{=html}(operator)`</small>`{=html}\
\> : greater than sign `<small>`{=html}(operator)`</small>`{=html}\
\| : vertical line

## Compound character delimiters

=\> : arrow\
.. : double dot\
\*\* : double star, exponentiate `<small>`{=html}(operator)`</small>`{=html}\
:= : assignment\
/= : inequality `<small>`{=html}(operator)`</small>`{=html}\
\>= : greater than or equal to `<small>`{=html}(operator)`</small>`{=html}\
\<= : less than or equal to `<small>`{=html}(operator)`</small>`{=html}\
\<\< : left label bracket\
\>\> : right label bracket\
\<\> : box

## Others

The following ones are special characters but not delimiters.

\" : quotation mark, used for string literals.\
\# : number sign, used in based numeric literals.

The following special characters are unused in Ada code - they are
illegal except within string literals and comments (they are used in the
Reference Manual Backus-Naur syntax definition of Ada):

\[ : left square bracket\
\] : right square bracket\
{ : left curly bracket\
} : right curly bracket

## See also

### Wikibook

-   Ada Programming

### Ada 95 Reference Manual

-
-
### Ada 2005 Reference Manual

-
-
Programming}}\|Delimiters


# Ada Programming/Operators

## Standard operators

Ada allows operator
overloading for all standard
operators and so the following summaries can only describe the suggested
standard operations for each operator. It is quite possible to misuse
any standard operator to perform something unusual.

Each operator is either a keyword
or a delimiter---hence all
operator pages are redirects to the appropriate
keyword or
delimiter.

Operators have arguments which in the RM are called Left and Right for
binary operators, Right for unary operators (indicating the position
with respect to the operator symbol).

The list is sorted from lowest precedence to highest precedence.

### Logical operators

and : and $x \land y$, `<small>`{=html}(also keyword and)`</small>`{=html}\
or : or $x \lor y$, `<small>`{=html}(also keyword or)`</small>`{=html}\
xor : exclusive or $(x \land \bar{y}) \lor (\bar{x} \land y)$, `<small>`{=html}(also keyword xor)`</small>`{=html}

### Relational operators

/= : Not Equal $x \ne y$, `<small>`{=html}(also special character /=)`</small>`{=html}\
= : Equal $x = y$, `<small>`{=html}(also special character =)`</small>`{=html}\
\< : Less than $x<y$, `<small>`{=html}(also special character \<)`</small>`{=html}\
\<= : Less than or equal to ($x \le y$), `<small>`{=html}(also special character \<=)`</small>`{=html}\
\> : Greater than ($x > y$), `<small>`{=html}(also special character \>)`</small>`{=html}\
\>= : Greater than or equal to ($x \ge y$), `<small>`{=html}(also special character \>=)`</small>`{=html}

### Binary adding operators

+ : Add $x + y$, `<small>`{=html}(also special character +)`</small>`{=html}\
- : Subtract $x - y$, `<small>`{=html}(also special character -)`</small>`{=html}\
& : Concatenate , $x$ & $y$, `<small>`{=html}(also special character &)`</small>`{=html}

### Unary adding operators

+ : Plus sign $+x$, `<small>`{=html}(also special character +)`</small>`{=html}\
- : Minus sign $-x$, `<small>`{=html}(also special character -)`</small>`{=html}

### Multiplying operator

\* : Multiply, $x \times y$, `<small>`{=html}(also special character \*)`</small>`{=html}\
/ : Divide $x / y$, `<small>`{=html}(also special character /)`</small>`{=html}\
mod : modulus `<small>`{=html}(also keyword mod)`</small>`{=html}\
rem : remainder `<small>`{=html}(also keyword rem)`</small>`{=html}

### Highest precedence operator

\*\* : Power $x^y$, `<small>`{=html}(also special character \*\*)`</small>`{=html}\
not : logical not $\lnot x$, `<small>`{=html}(also keyword not)`</small>`{=html}\
abs : absolute value `<small>`{=html} $|x|$ (also keyword abs)`</small>`{=html}

## Short-circuit control forms

These are not operators and thus cannot be overloaded.

and then : *e.g.* **`if`**` Y /= 0 `**`and then`**` X/Y > Limit `**`then`**` ...`\
or else : *e.g.* **`if`**` Ptr = `**`null`**` `**`or else`**` Ptr.I = 0 `**`then`**` ...`

## Membership tests

The Membership Tests also cannot be overloaded because they are not
operators.

in : element of, $var \in type$, *e.g.* ` I `` Positive `, `<small>`{=html}(also keyword )`</small>`{=html}\
not in : not element of, $var \notin type$, *e.g.* ` I `` `` Positive `, `<small>`{=html}(also keywords  )`</small>`{=html}

### Range membership test

` Today `` `` Tuesday .. Thursday `\
`   ...`

### Subtype membership test

`Is_Non_Negative := X `` Natural;`

### Class membership test

` `` Object `` Circle'``;`

### Range membership test

` Today `` `` Tuesday .. Thursday `\
`   ...`

### Choice list membership test

Ada 2012 extended the membership tests to include the union
(short-circuit or) of several range or value choices.

` Today `` Monday .. Wednesday | Friday `\
`   ...`

## See also

### Wikibook

-   Ada Programming

### Ada 95 Reference Manual

-
### Ada 2005 Reference Manual

-
### Ada Quality and Style Guide

-
-
-
Programming}}\|Operators

es:Programación en
Ada/Operadores


# Ada Programming/Attributes

subprograms are declared, certain properties thereof normally are left
to the compiler to specify (like the size or the address of a variable,
the calling convention of a subprogram). Properties which may be queried
are called *Attributes*; those which may be specified are called
Aspects. Aspects and attributes
are defined in the Ada Reference Manual annex
.

## Language summary attributes

The concept of **attributes** is pretty unique to
Ada. Attributes allow you to get ---and
sometimes set--- information about objects or other language entities
such as types. A good example is the
 attribute. It describes the size of
an object or a type in bits.

`A : Natural := Integer'``; `

However, unlike the  operator
from C/C++ the
 attribute can also be set:

` Byte `` `` -128 .. 127;  `\
`                                 `\
`  Byte'`` `` 8;            `

Of course not all attributes can be set. An attribute starts with a tick
\' and is followed by its name. The compiler determines by context if
the tick is the beginning of an attribute, a character literal or a
quantified expression.

`A : Character := Character'`` (32);     `\
`B : Character := ' ';                    `\
`S : String    := Character'(')')'Image;  `

## List of language defined attributes

Ada 2005 : This is a new Ada 2005 attribute.\
Ada 2012 : This is a new Ada 2012 attribute.\
Obsolescent : This is a deprecated attribute and should not be used in new code.

### A -- B

-   \'Access
-   \'Address
-   \'Adjacent
-   \'Aft
-   \'Alignment
-   \'Base
-   \'Bit_Order
-   \'Body_Version

### C

-   \'Callable
-   \'Caller
-   \'Ceiling
-   \'Class
-   \'Component_Size
-   \'Compose
-   \'Constrained
-   \'Copy_Sign
-   \'Count

### D -- F

-   \'Definite
-   \'Delta
-   \'Denorm
-   \'Digits
-   \'Emax
    `<small>`{=html}(Obsolescent)`</small>`{=html}
-   \'Exponent
-   \'External_Tag
-   \'Epsilon
    `<small>`{=html}(Obsolescent)`</small>`{=html}
-   \'First
-   \'First_Bit
-   \'Floor
-   \'Fore
-   \'Fraction

### G -- L

-   \'Has_Same_Storage
    `<small>`{=html}(Ada 2012)`</small>`{=html}
-   \'Identity
-   \'Image
-   \'Input
-   \'Large
    `<small>`{=html}(Obsolescent)`</small>`{=html}
-   \'Last
-   \'Last_Bit
-   \'Leading_Part
-   \'Length

### M

-   \'Machine
-   \'Machine_Emax
-   \'Machine_Emin
-   \'Machine_Mantissa
-   \'Machine_Overflows
-   \'Machine_Radix
-   \'Machine_Rounding
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   \'Machine_Rounds
-   \'Mantissa
    `<small>`{=html}(Obsolescent)`</small>`{=html}
-   \'Max
-   \'Max_Alignment_For_Allocation
    `<small>`{=html}(Ada 2012)`</small>`{=html}
-   \'Max_Size_In_Storage_Elements
-   \'Min
-   \'Mod
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   \'Model
-   \'Model_Emin
-   \'Model_Epsilon
-   \'Model_Mantissa
-   \'Model_Small
-   \'Modulus

### O -- R

-   \'Old
    `<small>`{=html}(Ada 2012)`</small>`{=html}
-   \'Output
-   \'Overlaps_Storage
    `<small>`{=html}(Ada 2012)`</small>`{=html}
-   \'Partition_ID
-   \'Pos
-   \'Position
-   \'Pred
-   \'Priority
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   \'Range
-   \'Read
-   \'Remainder
-   \'Result
    `<small>`{=html}(Ada 2012)`</small>`{=html}
-   \'Round
-   \'Rounding

### S

-   \'Safe_Emax
    `<small>`{=html}(Obsolescent)`</small>`{=html}
-   \'Safe_First
-   \'Safe_Large
    `<small>`{=html}(Obsolescent)`</small>`{=html}
-   \'Safe_Last
-   \'Safe_Small
    `<small>`{=html}(Obsolescent)`</small>`{=html}
-   \'Scale
-   \'Scaling
-   \'Signed_Zeros
-   \'Size
-   \'Small
-   \'Storage_Pool
-   \'Storage_Size
-   \'Stream_Size
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   \'Succ

### T -- V

-   \'Tag
-   \'Terminated
-   \'Truncation
-   \'Unbiased_Rounding
-   \'Unchecked_Access
-   \'Val
-   \'Valid
-   \'Value
-   \'Version

### W -- Z

-   \'Wide_Image
-   \'Wide_Value
-   \'Wide_Wide_Image
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   \'Wide_Wide_Value
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   \'Wide_Wide_Width
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   \'Wide_Width
-   \'Width
-   \'Write

## List of implementation defined attributes

The following attributes are not available in all Ada compilers, only in
those that had implemented them.

Currently, there are only listed the implementation-defined attributes
of a few compilers. You can help Wikibooks
adding
specific attributes of other compilers:

GNAT : Implementation-defined attribute of the GNAT compiler from AdaCore/FSF.\
HP Ada : Implementation-defined attribute of the HP Ada compiler (formerly known as \"DEC Ada\").\
ICC : Implementation-defined attribute[^1] of the Irvine ICC compiler.\
PowerAda : Implementation-defined attribute of OC Systems\' PowerAda.\
SPARCompiler : Implementation-defined attribute of Sun\'s SPARCompiler Ada.

### A -- D

-   \'Abort_Signal
    (GNAT)
-   \'Address_Size
    (GNAT)
-   \'Architecture
    (ICC)
-   \'Asm_Input
    (GNAT)
-   \'Asm_Output
    (GNAT)
-   \'AST_Entry
    (GNAT, HP Ada)
-   \'Bit (GNAT, HP Ada)
-   \'Bit_Position
    (GNAT)
-   \'CG_Mode (ICC)
-   \'Code_Address
    (GNAT)
-   \'Compiler_Key
    (SPARCompiler)
-   \'Compiler_Version
    (SPARCompiler)
-   \'Declared (ICC)
-   \'Default_Bit_Order
    (GNAT)
-   \'Dope_Address
    (SPARCompiler)
-   \'Dope_Size
    (SPARCompiler)

### E -- H

-   \'Elaborated
    (GNAT)
-   \'Elab_Body
    (GNAT)
-   \'Elab_Spec
    (GNAT)
-   \'Emax (GNAT)
-   \'Enabled (GNAT)
-   \'Entry_Number
    (SPARCompiler)
-   \'Enum_Rep (GNAT)
-   \'Enum_Val (GNAT)
-   \'Epsilon (GNAT)
-   \'Exception_Address
    (ICC)
-   \'Extended_Aft
    (PowerAda)
-   \'Extended_Base
    (PowerAda)
-   \'Extended_Digits
    (PowerAda)
-   \'Extended_Fore
    (PowerAda)
-   \'Extended_Image
    (PowerAda)
-   \'Extended_Value
    (PowerAda)
-   \'Extended_Width
    (PowerAda)
-   \'Extended_Wide_Image
    (PowerAda)
-   \'Extended_Wide_Value
    (PowerAda)
-   \'Extended_Wide_Width
    (PowerAda)
-   \'Fixed_Value
    (GNAT)
-   \'Has_Access_Values
    (GNAT)
-   \'Has_Discriminants
    (GNAT)
-   \'High_Word
    (ICC)
-   \'Homogeneous
    (SPARCompiler)

### I -- N

-   \'Img (GNAT)
-   \'Integer_Value
    (GNAT)
-   \'Invalid_Value
    (GNAT)
-   \'Linear_Address
    (ICC)
-   \'Low_Word (ICC)
-   \'Machine_Size
    (GNAT, HP Ada)
-   \'Max_Interrupt_Priority
    (GNAT)
-   \'Max_Priority
    (GNAT)
-   \'Maximum_Alignment
    (GNAT)
-   \'Mechanism_Code
    (GNAT)
-   \'Null_Parameter
    (GNAT, HP Ada)

### O -- T

-   \'Object_Size
    (GNAT)
-   \'Old (GNAT)
-   \'Passed_By_Reference
    (GNAT)
-   \'Pool_Address
    (GNAT)
-   \'Range_Length
    (GNAT)
-   \'Ref (SPARCompiler)
-   \'Storage_Unit
    (GNAT)
-   \'Stub_Type
    (GNAT)
-   \'Target (ICC)
-   \'Target_Name
    (GNAT)
-   \'Task_ID
    (SPARCompiler)
-   \'Tick (GNAT)
-   \'To_Address
    (GNAT)
-   \'Type_Class
    (GNAT, HP Ada)
-   \'Type_Key
    (SPARCompiler)

### U -- Z

-   \'UET_Address
    (GNAT)
-   \'Unconstrained_Array
    (GNAT)
-   \'Universal_Literal_String
    (GNAT)
-   \'Unrestricted_Access
    (GNAT, ICC)
-   \'VADS_Size
    (GNAT)
-   \'Value_Size
    (GNAT)
-   \'Wchar_T\_Size
    (GNAT)
-   \'Word_Size
    (GNAT)

## See also

### Wikibook

-   Ada Programming
-   Ada Programming/Aspects
-   Ada Programming/Pragmas
-   Ada Programming/Keywords

### Ada Reference Manual

#### Ada 83

-
-
#### Ada 95

-
-
#### Ada 2005

-
-
#### Ada 2012

-
-
## References

```{=html}
<references/>
```
Programming}}\|Attributes es:Programación
en Ada/Atributos

[^1]: \"4.2 ICC-Defined Attributes\", *ICC Ada Implementation Reference
    --- ICC Ada Version 8.2.5 for i960MC Targets*, document version
    2.11.4 1


# Ada Programming/Aspects

subprograms are declared, certain properties thereof normally are left
to the compiler to specify (like the size or the address of a variable,
the calling convention of a subprogram). Properties which may be queried
are called Attributes; those
which may be specified are called *Aspects*. Some aspects correspond
with attributes which then have the same name. Aspects and attributes
are defined in the Ada Reference Manual
,
pragmas in
.

## Description

*Aspects* are certain properties of an entity that may be specified,
depending on the kind of entity, by an aspect specification as part of
its declaration or by a separate attribute definition clause or pragma
declaration.

`Aspect_Specification ::=`\
`  `` `*`Aspect_Name`*` [ => `*`Aspect_Definition`*`] {,`\
`       `*`Aspect_Name`*` [ => `*`Aspect_Definition`*`] } ;`

`Attribute_Definition_Clause ::= `\
`     `` entity_name'attribute_designator `` expression;`\
`   | `` entity_name'attribute_designator `` name;`

` Name (Parameter_List);`

If an aspect is not specified, it depends on the aspect itself whether
its value is left to the compiler or prescribed in the Ada RM.

The specification of a `Boolean` valued aspect may omit the aspect
definition, which then has the value `True`.

Examples of such properties are the size of a type, i.e. the number of
bits a stand-alone object of that type will use; or that a subprogram
will not return from its call: aspect
. This latter one is an
example of an aspect that has a `Boolean` value.

## List of language defined aspects

If not marked otherwise, an aspect is specified by an
*Aspect_Specification*.

An aspect marked *Ada 2012* is an
Ada 2012 language functionality
not available in previous Ada generations. Aspects not so marked were
previously defined via pragmas or attribute definition clauses. This is
still possible, but deprecated.

### A -- D

-   Address
    `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-   Alignment
    `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-       `<small>`{=html}(Pragma)`</small>`{=html}

-
-
-
-
-   Bit_Order
    `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-   Coding
    `<small>`{=html}(Enumeration_Representation_Clause)`</small>`{=html}

-   Component_Size
    `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-
-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-       `<small>`{=html}(Ada 2012; Pragma)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-       `<small>`{=html}(Ada 2012; Aspect_Specification,
    Pragma)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

### E -- O

-       `<small>`{=html}(Pragma)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-
-
-       `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-
-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-
-       `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-       `<small>`{=html}(Ada 2012;
    Attribute_Definition_Clause)`</small>`{=html}

-
-
-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-   Layout
    `<small>`{=html}(Record_Representation_Clause)`</small>`{=html}

-
-   Machine_Radix
    `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-
-       `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-       `<small>`{=html}(Ada 2012;
    Attribute_Definition_Clause)`</small>`{=html}

### P -- Z

-
-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-       `<small>`{=html}(Pragma)`</small>`{=html}

-
-       `<small>`{=html}(Pragma)`</small>`{=html}

-       `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-       `<small>`{=html}(Ada 2012;
    Attribute_Definition_Clause)`</small>`{=html}

-
-       `<small>`{=html}(Pragma)`</small>`{=html}

-       `<small>`{=html}(Pragma)`</small>`{=html}

-       `<small>`{=html}(Pragma)`</small>`{=html}

-   Size
    `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-       `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-       `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-       `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-       `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-
-       `<small>`{=html}(Ada 2012)`</small>`{=html}

-
-
-       `<small>`{=html}(Attribute_Definition_Clause)`</small>`{=html}

-       `<small>`{=html}(Ada 2012;
    Attribute_Definition_Clause)`</small>`{=html}

## List of implementation defined aspects

The following pragmas are not available in all Ada compilers, only in
those that had implemented them.

Currently, there are only listed the implementation-defined pragmas of a
few compilers. You can help Wikibooks
adding
specific aspects of other compilers:

GNAT : Implementation defined aspect of the GNAT compiler from AdaCore and FSF.

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

-       `<small>`{=html}(GNAT)`</small>`{=html}

## See also

### Wikibook

-   Ada Programming
-   Ada Programming/Attributes
-   Ada Programming/Keywords
-   Ada Programming/Pragmas

### Ada Reference Manual

#### Ada 2012

-
-
-
## References

```{=html}
<references/>
```
Programming}}\|Aspects


# Ada Programming/Pragmas

## Description

Pragmas control the compiler, i.e.
they are compiler directives. They
have the standard form of

` `*`Name`*` (`*`Parameter_List`*`);`

where the parameter list is optional.

## List of language defined pragmas

Some pragmas are specially marked:

Ada 2005 : This is a new Ada 2005 pragma.\
Ada 2012 : This is a new Ada 2012 pragma.\
Obsolescent : This is a deprecated pragma and it should not be used in new code.

### A -- H

-   All_Calls_Remote
-   Assert
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   Assertion_Policy
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   Asynchronous
    `<small>`{=html}(Obsolescent since Ada 2012)`</small>`{=html}
-   Atomic
    `<small>`{=html}(Obsolescent since Ada 2012)`</small>`{=html}
-   Atomic_Components
    `<small>`{=html}(Obsolescent since Ada 2012)`</small>`{=html}
-   Attach_Handler
    `<small>`{=html}(Obsolescent since Ada 2012)`</small>`{=html}
-   Controlled
    `<small>`{=html}(Removed from Ada 2012)`</small>`{=html}
-   Convention
    `<small>`{=html}(Obsolescent since Ada 2012)`</small>`{=html}
-   CPU
    `<small>`{=html}(Ada 2012)`</small>`{=html}
-   Default_Storage_Pool
    `<small>`{=html}(Ada 2012)`</small>`{=html}
-   Detect_Blocking
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   Discard_Names
-   Dispatching_Domain
    `<small>`{=html}(Ada 2012)`</small>`{=html}
-   Elaborate
-   Elaborate_All
-   Elaborate_Body
-   Export
    `<small>`{=html}(Obsolescent since Ada 2012)`</small>`{=html}

### I -- O

-   Import
    `<small>`{=html}(Obsolescent since Ada 2012)`</small>`{=html}
-   Independent
    `<small>`{=html}(Ada 2012)`</small>`{=html}
-   Independent_Component
    `<small>`{=html}(Ada 2012)`</small>`{=html}
-   Inline
    `<small>`{=html}(Obsolescent since Ada 2012)`</small>`{=html}
-   Inspection_Point
-   Interface
    `<small>`{=html}(Obsolescent)`</small>`{=html}
-   Interrupt_Handler
    `<small>`{=html}(Obsolescent since Ada 2012)`</small>`{=html}
-   Interrupt_Priority
    `<small>`{=html}(Obsolescent since Ada 2012)`</small>`{=html}
-   Linker_Options
-   List
-   Locking_Policy
-   Memory_Size
    `<small>`{=html}(Obsolescent)`</small>`{=html}
-   No_Return
    `<small>`{=html}(Ada 2005)`</small>`{=html}
    `<small>`{=html}(Obsolescent since Ada 2012)`</small>`{=html}
-   Normalize_Scalars
-   Optimize

### P -- R

-   Pack
    `<small>`{=html}(Obsolescent since Ada 2012)`</small>`{=html}
-   Page
-   Partition_Elaboration_Policy
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   Preelaborable_Initialization
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   Preelaborate
-   Priority
    `<small>`{=html}(Obsolescent since Ada 2012)`</small>`{=html}
-   Priority_Specific_Dispatching
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   Profile
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   Pure
-   Queueing_Policy
-   Relative_Deadline
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   Remote_Call_Interface
-   Remote_Types
-   Restrictions
-   Reviewable

### S -- Z

-   Shared
    `<small>`{=html}(Obsolescent)`</small>`{=html}
-   Shared_Passive
-   Storage_Size
-   Storage_Unit
    `<small>`{=html}(Obsolescent)`</small>`{=html}
-   Suppress
-   System_Name
    `<small>`{=html}(Obsolescent)`</small>`{=html}
-   Task_Dispatching_Policy
-   Unchecked_Union
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   Unsuppress
    `<small>`{=html}(Ada 2005)`</small>`{=html}
-   Volatile
-   Volatile_Components

## List of implementation defined pragmas

The following pragmas are not available in all Ada compilers, only in
those that had implemented them.

Currently, there are only listed the implementation-defined pragmas of a
few compilers. You can help Wikibooks
adding
specific aspects of other compilers:

GNAT : Implementation defined pragma of the GNAT compiler from AdaCore and FSF.\
HP Ada : Implementation defined pragma of the HP Ada compiler (formerly known as \"DEC Ada\").\
ICC : Implementation-defined pragma[^1] of the Irvine ICC compiler.\
PowerAda : Implementation defined pragma of OC Systems\' PowerAda.\
SPARCompiler : Implementation defined pragma of Sun\'s SPARCompiler Ada.2

### A -- C

-   Abort_Defer
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Ada_83
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Ada_95
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Ada_05
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Ada_2005
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Ada_12
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Ada_2012
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Annotate
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Assume_No_Invalid_Values
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Ast_Entry
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   Bit_Pack
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Built_In
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Byte_Pack
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   C_Pass_By_Copy
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Call_Mechanism
    `<small>`{=html}(ICC)`</small>`{=html}
-   Canonical_Streams
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Check
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Check_Name
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Check_Policy
    `<small>`{=html}(GNAT)`</small>`{=html}
-   CM_Info
    `<small>`{=html}(PowerAda)`</small>`{=html}
-   Comment
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Common_Object
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   Compatible_Calls
    `<small>`{=html}(ICC)`</small>`{=html}
-   Compile_Time_Error
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Compile_Time_Warning
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Complete_Representation
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Complex_Representation
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Component_Alignment
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   Compress
    `<small>`{=html}(ICC)`</small>`{=html}
-   Constrain_Private
    `<small>`{=html}(ICC)`</small>`{=html}
-   Convention_Identifier
    `<small>`{=html}(GNAT)`</small>`{=html}
-   CPP_Class
    `<small>`{=html}(GNAT)`</small>`{=html}
-   CPP_Constructor
    `<small>`{=html}(GNAT)`</small>`{=html}
-   CPP_Virtual
    `<small>`{=html}(GNAT)`</small>`{=html}
-   CPP_Vtable
    `<small>`{=html}(GNAT)`</small>`{=html}

### D -- H

-   Data_Mechanism
    `<small>`{=html}(ICC)`</small>`{=html}
-   Debug
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Debug_Policy
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Delete_Subprogram_Entry
    `<small>`{=html}(ICC)`</small>`{=html}
-   Elaboration_Checks
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Eliminate
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Error
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Export_Exception
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   Export_Function
    `<small>`{=html}(GNAT, HP Ada, SPARCompiler)`</small>`{=html}
-   Export_Mechanism
    `<small>`{=html}(ICC)`</small>`{=html}
-   Export_Object
    `<small>`{=html}(GNAT, HP Ada, SPARCompiler)`</small>`{=html}
-   Export_Procedure
    `<small>`{=html}(GNAT, HP Ada, SPARCompiler)`</small>`{=html}
-   Export_Value
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Export_Valued_Procedure
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   Extend_System
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Extensions_Allowed
    `<small>`{=html}(GNAT)`</small>`{=html}
-   External
    `<small>`{=html}(GNAT, SPARCompiler)`</small>`{=html}
-   External_Name
    `<small>`{=html}(ICC, SPARCompiler)`</small>`{=html}
-   External_Name_Casing
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Fast_Math
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Favor_Top_Level
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Finalize_Storage_Only
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Float_Representation
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   Foreign
    `<small>`{=html}(ICC)`</small>`{=html}
-   Generic_Mechanism
    `<small>`{=html}(ICC)`</small>`{=html}
-   Generic_Policy
    `<small>`{=html}(SPARCompiler)`</small>`{=html}

### I -- L

-   i960_Intrinsic
    `<small>`{=html}(ICC)`</small>`{=html}
-   Ident
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   Images
    `<small>`{=html}(PowerAda)`</small>`{=html}
-   Implemented,
    previously named \'Implemented_By_Entry\'
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Implicit_Code
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Implicit_Packing
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Import_Exception
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   Import_Function
    `<small>`{=html}(GNAT, HP Ada, SPARCompiler)`</small>`{=html}
-   Import_Mechanism
    `<small>`{=html}(ICC)`</small>`{=html}
-   Import_Object
    `<small>`{=html}(GNAT, HP Ada, SPARCompiler)`</small>`{=html}
-   Import_Procedure
    `<small>`{=html}(GNAT, HP Ada, SPARCompiler)`</small>`{=html}
-   Import_Valued_Procedure
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   Include
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Initialize
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Initialize_Scalars
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Inline_Always
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Inline_Generic
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   Inline_Only
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Instance_Policy
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Interface_Constant
    `<small>`{=html}(ICC)`</small>`{=html}
-   Interface_Information
    `<small>`{=html}(PowerAda)`</small>`{=html}
-   Interface_Mechanism
    `<small>`{=html}(ICC)`</small>`{=html}
-   Interface_Name
    `<small>`{=html}(GNAT, HP Ada, ICC, SPARCompiler)`</small>`{=html}
-   Interrupt_State
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Invariant
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Keep_Names
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Label
    `<small>`{=html}(ICC)`</small>`{=html}
-   License
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Link_With
    `<small>`{=html}(GNAT, ICC, SPARCompiler)`</small>`{=html}
-   Linker_Alias
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Linker_Constructor
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Linker_Destructor
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Linker_Section
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Long_Float
    `<small>`{=html}(GNAT: OpenVMS, HP Ada)`</small>`{=html}

### M -- P

-   Machine_Attribute
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Main
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Main_Storage
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   No_Body
    `<small>`{=html}(GNAT)`</small>`{=html}
-   No_Image
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   No_Strict_Aliasing
    `<small>`{=html}(GNAT)`</small>`{=html}
-   No_Suppress
    `<small>`{=html}(PowerAda)`</small>`{=html}
-   No_Reorder
    `<small>`{=html}(ICC)`</small>`{=html}
-   No_Zero
    `<small>`{=html}(ICC)`</small>`{=html}
-   Noinline
    `<small>`{=html}(ICC)`</small>`{=html}
-   Non_Reentrant
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Not_Elaborated
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Not_Null
    `<small>`{=html}(ICC)`</small>`{=html}
-   Obsolescent
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Optimize_Alignment
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Optimize_Code
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Optimize_Options
    `<small>`{=html}(ICC)`</small>`{=html}
-   Ordered
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Parameter_Mechanism
    `<small>`{=html}(ICC)`</small>`{=html}
-   Passive
    `<small>`{=html}(GNAT, HP Ada, SPARCompiler)`</small>`{=html}
-   Persistent_BSS
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Physical_Address
    `<small>`{=html}(ICC)`</small>`{=html}
-   Polling
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Postcondition
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Precondition
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Preserve_Layout
    `<small>`{=html}(PowerAda)`</small>`{=html}
-   Profile_Warnings
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Propagate_Exceptions
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Protect_Registers
    `<small>`{=html}(ICC)`</small>`{=html}
-   Protected_Call
    `<small>`{=html}(ICC)`</small>`{=html}
-   Protected_Return
    `<small>`{=html}(ICC)`</small>`{=html}
-   Psect_Object
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   Pure_Function
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Put
    `<small>`{=html}(ICC)`</small>`{=html}
-   Put_Line
    `<small>`{=html}(ICC)`</small>`{=html}

### R -- S

-   Reserve_Registers
    `<small>`{=html}(ICC)`</small>`{=html}
-   Restriction_Warnings
    `<small>`{=html}(GNAT)`</small>`{=html}
-   RTS_Interface
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   SCCS_ID
    `<small>`{=html}(PowerAda)`</small>`{=html}
-   Share_Body
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Share_Code
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Share_Generic
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   Shareable
    `<small>`{=html}(ICC)`</small>`{=html}
-   Short_Circuit_And_Or
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Short_Descriptors
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Simple_Storage_Pool_Type
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Simple_Task
    `<small>`{=html}(ICC)`</small>`{=html}
-   Source_File_Name
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Source_File_Name_Project
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Source_Reference
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Stack_Size
    `<small>`{=html}(ICC)`</small>`{=html}
-   Static_Elaboration
    `<small>`{=html}(ICC)`</small>`{=html}
-   Static_Elaboration_Desired
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Stream_Convert
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Style_Checks
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Subtitle
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Suppress_All
    `<small>`{=html}(GNAT, HP Ada, PowerAda,
    SPARCompiler)`</small>`{=html}
-   Suppress_Elaboration_Checks
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Suppress_Exception_Locations
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Suppress_Initialization
    `<small>`{=html}(GNAT)`</small>`{=html}
-   System_Table
    `<small>`{=html}(ICC)`</small>`{=html}

### T -- Z

-   Task_Attributes
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Task_Info
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Task_Name
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Task_Storage
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   Test_Case
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Thread_Body
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Thread_Local_Storage
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Time_Slice
    `<small>`{=html}(GNAT, HP Ada, ICC)`</small>`{=html}
-   Time_Slice_Attributes
    `<small>`{=html}(ICC)`</small>`{=html}
-   Title
    `<small>`{=html}(GNAT, HP Ada)`</small>`{=html}
-   Unimplemented_Unit
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Universal_Aliasing
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Universal_Data
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Unmodified
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Unreferenced
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Unreferenced_Objects
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Unreserve_All_Interrupts
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Unsigned_Literal
    `<small>`{=html}(ICC)`</small>`{=html}
-   Use_VADS_Size
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Validity_Checks
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Warning
    `<small>`{=html}(SPARCompiler)`</small>`{=html}
-   Warnings
    `<small>`{=html}(GNAT, SPARCompiler)`</small>`{=html}
-   Weak_External
    `<small>`{=html}(GNAT)`</small>`{=html}
-   Wide_Character_Encoding
    `<small>`{=html}(GNAT)`</small>`{=html}

## See also

### Wikibook

-   Ada Programming
-   Ada Programming/Aspects
-   Ada Programming/Attributes
-   Ada Programming/Keywords

### Ada Reference Manual

#### Ada 83

-
-
#### Ada 95

-
-
#### Ada 2005

-
-
#### Ada 2012

-
-
## References

```{=html}
<references/>
```
Programming}}\|Pragmas Ada
Programming}}/Ada 2005 feature\|Pragmas

es:Programación en
Ada/Pragmas

[^1]: \"2.2 ICC-Defined Pragmas\", *ICC Ada Implementation Reference ---
    ICC Ada Version 8.2.5 for i960MC Targets*, document version
    2.11.4.1


# Ada Programming/Libraries

## Predefined Language Libraries

Ada\'s built-in library is provided by three root library units: Ada,
Interfaces, and System; other library units are children of these. The
library is quite extensive and well-structured. These chapters too are
more reference like. Most specifications included in them have been
obtained from the reznikmm/adalib
repository.

The package Standard contains all predefined identifiers in the
language.

-   Standard
-   Ada
-   Interfaces
-   System

Ada 83 had a much smaller library
and did not yet have this library structure. These root libraries were
introduced in Ada 95 to inhibit a
*name pollution*. To preserve compatibility, there exist renamings of
all Ada 83 library units `XXX` as `Ada.XXX` respectively `System.XXX`;
see RM .
Contrary to the names in the root hierarchies, the original Ada 83 names
`XXX` are not protected -- they may be reused for user-defined library
units.

## Implementation-Defined Language Libraries

Every Ada implementation has as an extension of the predefined Ada
library. One example is the library provided by the
GNAT implementation.

-   GNAT

## Other Language Libraries

Other libraries which are not part of the standard but freely available.

-   Multi Purpose
-   Container
    Libraries
-   GUI Libraries
-   Distributed
    Objects
-   Database
-   Web Programming
-   Input/Output

## See also

### Wikibook

-   Ada Programming

### Ada Reference Manual

-
### Resources

-   A collection of Tools and
    Libraries
    maintained by the Ada Resource Association.
-   The collection of crates of
    Alire, a package manager for Ada
    libraries and applications in source form.

Programming}}\|Libraries

es:Programación en Ada/Unidades
predefinidas


# Ada Programming/Portals

## Forges of open-source projects

SourceForge : Currently, there are more than 200 Ada projects hosted at SourceForge --- including the example programs for Ada Programming wikibook.

```{=html}
<!-- -->
```

GitHub : A source code repository based on Git with many recent developments.\
Codeberg : Codeberg is a democratic community-driven, non-profit software development platform. It contains a few Ada projects.

```{=html}
<!-- -->
```

Ada-centric forges: There are some Ada-centric forges/catalogues hosted by Ada associations and individuals:

:\* <http://codelabs.ch>

:\* <http://www.adaforge.org>

## Directories of freely available tools and libraries

Ada Information Clearinghouse --- Free Tools and Libraries

```{=html}
<!-- -->
```

Open Hub (language summary, ada tag, language search): Open Hub is a directory of Open Source projects. Its main features are source code analysis of public repositories and public reviews of projects.

## Collections of Ada source code

The Public Ada Library (PAL) : The PAL is a library of Ada and VHDL software, information, and courseware that contains over 1 BILLION bytes of material (mainly in compressed form). All items in the PAL have been released to the public with unlimited distribution, and, in most cases (the exceptions are shareware), the items are freeware.

```{=html}
<!-- -->
```

Ada and Software Engineering Library Version 2 (ASE2) : *The ASE2 Library contains over 1.1GB of material on Ada and Software Engineering assembled through a collaboration with over 60 organizations*. Walnut Creek CD-ROM once sold copies of this library. Nowadays, it is no longer maintained, but is still hosted in the archive.adaic.com server. It may contain useful resources, but it is highly redundant with other libraries.

```{=html}
<!-- -->
```

AdaPower : A directory and collection of Ada tools and resources.

## See also

### Wikibook

-   Ada Programming
-   Ada Programming/Tutorials
-   Ada Programming/Web 2.0


# Ada Programming/Tutorials

This page contains a list of other Ada tutorials on the Net.

1.  Ada Programming, available on
    Wikibooks, is based on the Ada
    2005 standard and currently
    being updated to Ada 2012.
2.  Introduction to Ada at
    learn.adacore.com
    is an interactive web tutorial based on Ada 2012. It has editable
    and compilable examples.
3.  Lovelace is a free (no-charge),
    self-directed Ada 95 tutorial available on the World Wide Web (WWW).
    Lovelace assumes that the user already knows another algorithmic
    programming language, such as C, C++, or Pascal. Lovelace is
    interactive and contains many short sections, most of which end with
    a question to help ensure that users understand the material.
    Lovelace can be used directly from the WWW, downloaded, or run from
    CD-ROM. Lovelace was developed by David A. Wheeler.
4.  AdaTutor is
    an interactive Ada 95 tutorial that was distributed as a
    public-domain Ada
    program
    and has been converted to a web tutorial.
5.  The Ada-95: A guide for C and C++
    programmers is a short
    hypertext tutorial for programmers who have a C or C++ style
    programming language background. It was written by Simon Johnston,
    with some additional text by Tucker Taft. PDF
    edition.
6.  Dale Stanbrough\'s
    Introduction is a
    set of notes that provide a simple introduction to Ada. This
    material has been used for a few years as a simple introduction to
    the language.
7.  Coronado Enterprises Ada 95 Tutorial: shareware
    edition.

Programming}}\|Tutorials


# Ada Programming/Web 2.0

\_\_TOC\_\_

Here is a list of Web 2.0 resources
about Ada:

## News & Blogs

-   reddit.com --- Ada
    \`<small>`{=html}[RSS`</small>`{=html}\],
    social news website on which users can post links to content on the
    web
-   Stack Overflow --- Ada
    questions
-   Ada Gems, programming tips and
    articles about specific language features
-   Ada Planet, news aggregator.
-   Ada Programming blog
    \`<small>`{=html}[RSS`</small>`{=html}\],
    by Martin Krischik and other authors
-   Java 2 Ada
    \`<small>`{=html}[RSS`</small>`{=html}\]

## Social Networks

-   \@AdaProgrammers at Twitter
-   Linked In --- Ada developers
    group (free register
    needed)
-   Gitter chat room

## General Info

-   Ada Resource Association
-   Awesome Ada, a curated
    list of awesome resources related to the Ada and SPARK programming
    language.
-   SlideShare, presentations about Ada
    programming, Ada
    95, Ada
    2005, Ada
    2012 tag pages.
-   Open Hub, a directory of Open
    Source projects. Its main features are source code
    analysis of public repositories
    and public reviews of projects
-   Ada@Krischik, Ada homepage of Martin
    Krischik
-   WikiCFP --- Calls For Papers on
    Ada
    \`<small>`{=html}[RSS`</small>`{=html}\]
-   AdaCore channel on
    youtube.com, Ada related
    videos.

## Wikimedia projects

-   **Wikipedia articles** (Ada
    category "wikilink")):
    -   Ada "wikilink")
    -   Jean Ichbiah
    -   Beaujolais effect
    -   ISO 8652
    -   Ada Semantic Interface
        Specification
    -   \...
-   **Wiktionary entries**:
    -   ACATS
    -   Ada
    -   ASIS
-   **Wikisource documents**:
    -   Steelman language
        requirements
    -   Stoneman requirements
-   **Wikibooks tutorials**:
    -   *Programación en Ada*, in
        Spanish
    -   *Programmation Ada*, in
        French
    -   *Ada*, in Italian
-   **Wikiquote**:
    -   Programming languages ---
        Ada
-   **Wikiversity**:
    -   Ada course

## Source code

-   Examples *Ada Programming*
    wikibook
-   Rosetta Code --- Ada
    Category, programming examples
    in multiple languages

## Projects

-   AdaCL
-   The Ada 95 Booch
    Components
-   The GNU Ada Compiler
-   ASIS
-   GLADE
-   Florist
-   GNAT --- GCC Wiki
-   RTEMSAda
-   AVR-Ada - Ada compiler for Atmel
    microcontrollers (Arduinos)
-   Ada Bare Bones - Tutorial to write a small Multiboot kernel written
    in Ada

Ada Programming}}\|Web 2.0