Ada Programming
Ada Programming
Wikibooks.org
March 22, 2013
On the 28th of April 2012 the contents of the English as well as German Wikibooks and Wikipedia
projects were licensed under Creative Commons Attribution-ShareAlike 3.0 Unported license. An
URI to this license is given in the list of figures on page 397. If this document is a derived work
from the contents of one of these projects and the content was still licensed by the project under
this license at the time of derivation this document has to be licensed under the same, a similar or a
compatible license, as stated in section 4b of the license. The list of contributors is included in chapter
Contributors on page 393. The licenses GPL, LGPL and GFDL are included in chapter Licenses on
page 399, since this book and/or parts of it may or may not be licensed under one or more of these
licenses, and thus require inclusion of these licenses. The licenses of the figures are given in the list of
figures on page 397. This PDF was generated by the LATEX typesetting software. The LATEX source
code is included as an attachment (source.7z.txt) in this PDF file. To extract the source from the
PDF file, we recommend the use of http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/
utility or clicking the paper clip attachment symbol on the lower left of your PDF Viewer, selecting
Save Attachment. After extracting it from the PDF file you have to rename it to source.7z. To
uncompress the resulting archive we recommend the use of http://www.7-zip.org/. The LATEX
source itself was generated by a program written by Dirk Hünniger, which is freely available under
an open source license from http://de.wikibooks.org/wiki/Benutzer:Dirk_Huenniger/wb2pdf.
This distribution also contains a configured version of the pdflatex compiler with all necessary
packages and fonts needed to compile the LATEX source included in this PDF file.
Contents
1 Basic Ada 3
1.1 "Hello, world!"programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Compiling the "Hello, world!"program . . . . . . . . . . . . . . . . . . . . 5
1.3 Things to look out for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4 Where to ask for help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2 Installing 9
2.1 AdaMagic from SofCheck . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 AdaMULTI from Green Hills Software . . . . . . . . . . . . . . . . . . . . 9
2.3 DEC Ada from HP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 GNAT, the GNU Ada Compiler from AdaCore and the Free Software
Foundation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5 ICC from Irvine Compiler Corporation . . . . . . . . . . . . . . . . . . . . 25
2.6 Janus/Ada 83 and 95 from RR Software . . . . . . . . . . . . . . . . . . . 25
2.7 MAXAda from Concurrent . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.8 ObjectAda from Atego (formerly Aonix) . . . . . . . . . . . . . . . . . . . 26
2.9 PowerAda from OC Systems . . . . . . . . . . . . . . . . . . . . . . . . . . 26
26section.2.10
2.11 SCORE from DDC-I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.12 XD Ada from SWEP-EDS . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.13 XGC Ada from XGC Software . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.14 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3 Building 29
3.1 Building with various compilers . . . . . . . . . . . . . . . . . . . . . . . . 29
3.2 Compiling our Demo Source . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.3 External links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4 Control Statements 37
4.1 Conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.2 Unconditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
4.3 Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.4 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5 Type System 45
5.1 Predefined types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.2 The Type Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.3 Concurrency Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.4 Limited Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
III
Contents
6 Integer types 69
6.1 Working demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6.2 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
8 Enumerations 73
8.1 Operators and attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
8.2 Enumeration literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
8.3 Enumeration subtypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
8.4 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
11 Arrays 83
11.1 Declaring arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
11.2 Using arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
11.3 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
12 Records 91
12.1 Basic record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
12.2 Null record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
12.3 Record Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
12.4 Discriminated record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
12.5 Variant record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
12.6 Union . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
12.7 Tagged record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
12.8 Abstract tagged record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
12.9 With aliased elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
12.10 Limited Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
IV
Contents
13 Access types 99
13.1 What's an Access Type? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
13.2 Pool access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
13.3 General access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
13.4 Anonymous access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
13.5 Implicit Dereference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
13.6 Null exclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
13.7 Access to Subprogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
13.8 Access FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
13.9 Thin and Fat Access Types . . . . . . . . . . . . . . . . . . . . . . . . . . 109
13.10 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
15 Strings 119
15.1 Fixed-length string handling . . . . . . . . . . . . . . . . . . . . . . . . . . 119
15.2 Bounded-length string handling . . . . . . . . . . . . . . . . . . . . . . . . 120
15.3 Unbounded-length string handling . . . . . . . . . . . . . . . . . . . . . . 122
15.4 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
16 Subprograms 125
16.1 Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
16.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
16.3 Named parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
16.4 Default parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
16.5 Renaming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
16.6 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
17 Packages 133
17.1 Separate compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
17.2 Parts of a package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
17.3 Using packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
17.4 Package organisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
17.5 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
17.6 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
V
Contents
19 Exceptions 153
19.1 Robustness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
19.2 Modules, preconditions and postconditions . . . . . . . . . . . . . . . . . . 153
19.3 Predefined exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
19.4 Input-output exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
19.5 Exception declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
19.6 Raising exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
19.7 Exception handling and propagation . . . . . . . . . . . . . . . . . . . . . 157
19.8 Information about an exception occurrence . . . . . . . . . . . . . . . . . 158
19.9 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
20 Generics 161
20.1 Parametric polymorphism (generic units) . . . . . . . . . . . . . . . . . . 161
20.2 Generic parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
20.3 Instantiating generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
20.4 Advanced generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
20.5 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
21 Tasking 173
21.1 Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
21.2 Protected types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
21.3 Entry families . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
21.4 Termination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
21.5 Timeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
21.6 Conditional entry calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
21.7 Requeue statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
21.8 Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
21.9 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
21.10 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
21.11 Ada Quality and Style Guide . . . . . . . . . . . . . . . . . . . . . . . . . 185
24 Containers 231
24.1 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
VI
Contents
25 Interfacing 243
25.1 Interfacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
25.2 Other programming languages . . . . . . . . . . . . . . . . . . . . . . . . . 243
25.3 Hardware devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
25.4 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
27 Tips 249
27.1 Full declaration of a type can be deferred to the unit's body . . . . . . . . 249
27.2 Lambda calculus through generics . . . . . . . . . . . . . . . . . . . . . . . 250
27.3 Compiler Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
27.4 Universal integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
27.5 I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
27.6 Quirks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
27.7 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
27.8 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
29 Algorithms 259
29.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
29.2 Chapter 1: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
29.3 Chapter 6: Dynamic Programming . . . . . . . . . . . . . . . . . . . . . . 261
32 Statements 283
VII
Contents
33 Variables 285
33.1 Assignment statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
33.2 Uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
33.3 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
35 Keywords 293
35.1 Language summary keywords . . . . . . . . . . . . . . . . . . . . . . . . . 293
35.2 List of keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
35.3 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
36 Delimiters 297
36.1 Single character delimiters . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
36.2 Compound character delimiters . . . . . . . . . . . . . . . . . . . . . . . . 298
36.3 Others . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
36.4 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
37 Operators 301
37.1 Standard operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
37.2 Short-circuit control forms . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
37.3 Membership tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
37.4 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
38 Attributes 305
38.1 Language summary attributes . . . . . . . . . . . . . . . . . . . . . . . . . 305
38.2 List of language defined attributes . . . . . . . . . . . . . . . . . . . . . . 305
38.3 List of implementation defined attributes . . . . . . . . . . . . . . . . . . . 310
38.4 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
38.5 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
39 Pragmas 317
39.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
39.2 List of language defined pragmas . . . . . . . . . . . . . . . . . . . . . . . 317
39.3 List of implementation defined pragmas . . . . . . . . . . . . . . . . . . . 320
39.4 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
39.5 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
40 Libraries 331
40.1 Predefined Language Libraries . . . . . . . . . . . . . . . . . . . . . . . . . 331
40.2 Other Language Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
40.3 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
VIII
Contents
57 Portals 383
57.1 Forges of open-source projects . . . . . . . . . . . . . . . . . . . . . . . . . 383
IX
Contents
58 Tutorials 387
60 Contributors 393
61 Licenses 399
61.1 GNU GENERAL PUBLIC LICENSE . . . . . . . . . . . . . . . . . . . . 399
61.2 GNU Free Documentation License . . . . . . . . . . . . . . . . . . . . . . 400
61.3 GNU Lesser General Public License . . . . . . . . . . . . . . . . . . . . . . 401
1
1 Basic Ada
File: hello_world_1.adb
with Ada.Text_IO
procedure Hello is
begin
Ada.Text_IO.Put_Line("Hello, world!");
end Hello;
The with statement adds the package Ada.Text_IO to the program. This package comes
with every Ada compiler and contains all functionality needed for textual Input/Output.
The with statement makes the declarations of Ada.Text_IO available to procedure Hello.
This includes the types declared in Ada.Text_IO, the subprograms of Ada.Text_IO and
everything else that is declared in Ada.Text_IO for public use. In Ada, packages can be
used as toolboxes. Text_IO provides a collection of tools for textual input and output in
one easy-to-access module. Here is a partial glimpse at package Ada.Text_IO
package Ada.Text_IO is
− − morestuf f
− − morestuf f
− − morestuf f
1 http://en.wikipedia.org/wiki/Syntax_%28programming_languages%29
2 http://en.wikipedia.org/wiki/Hello_world_program
3
Basic Ada
Next in the program we declare a main procedure. An Ada main procedure does not need
to be called "main". Any simple name is fine so here it is Hello. Compilers might allow
procedures or functions to be used as main subprograms. 3
The call on Ada.Text_IO.Put_Line writes the text "Hello World" to the current output file.
A with clause makes the content of a package visible by selection: we need to prefix the
procedure name Put_Line from the Text_IO package with its full package name Ada.Text_-
IO. If you need procedures from a package more often some form of shortcut is needed.
There are two options open:
By renaming a package it is possible to give a shorter alias to any package name.4 This
reduces the typing involved while still keeping some of the readability.
File: hello_world_2.adb
with Ada.Text_IO
procedure Hello is
package IO renames Ada.Text_IO;
begin
IO.Put_Line("Hello, world!");
IO.New_Line;
IO.Put_Line("I am an Ada program with package rename.");
end Hello;
The use clause makes all the content of a package directly visible. It allows even less typing
but removes some of the readability. One suggested "rule of thumb": use for the most used
package and renames for all other packages. You might have another rule (for example,
always use Ada.Text_IO. never use anything else).
3 Main subprograms may even have parameters; it is implementation-defined what kinds of subprograms
can be used as main subprograms. The reference manual explains the details in 10.2 LRM 10.2(29)
ˆ{http://www.adaic.org/resources/add_content/standards/05rm/html/RM-10-2.html} : “. . . , an
implementation is required to support all main subprograms that are public parameterless library
procedures.” Library means not nested in another subprogram, for example, and other things that
needn't concern us now.
4 renames can also be used for procedures, functions, variables, array elements. It can not be used for
types - a type rename can be accomplished with subtype.
4
Compiling the "Hello, world!" program
File: hello_world_3.adb
procedure Hello is
begin
Put_Line("Hello, world!");
New_Line;
Put_Line("I am an Ada program with package use.");
end Hello;
use can be used for packages and in the form of use type for types. use type makes only
the operators5 of the given type directly visible but not any other operations on the type.
For information on how to build the "Hello, world!" program on various compilers, see the
Building6 chapter.
Ada beginners frequently ask how it can be that such a simple program as "Hello, world!"
results in such a large executable. The reason has nothing to do with Ada but can usually
be found in the compiler and linker options used — or better, not used.
Standard behavior for Ada compilers — or good compilers in general — is not to create the
best code possible but to be optimized for ease of use. This is done to ensure a system that
works "out of the box" and thus does not frighten away potential new users with unneeded
complexity.
The GNAT project files, which you can download7 alongside the example programs, use
better tuned compiler, binder and linker options. If you use those your "Hello, world!" will
be a lot smaller:
32K ./Linux-i686-Debug/hello_world_1
8.0K ./Linux-i686-Release/hello_world_1
36K ./Linux-x86_64-Debug/hello_world_1
12K ./Linux-x86_64-Release/hello_world_1
1.1M ./Windows_NT-i686-Debug/hello_world_1.exe
16K ./Windows_NT-i686-Release/hello_world_1.exe
32K ./VMS-AXP-Debug/hello_world_1.exe
12K ./VMS-AXP-Release/hello_world_1.exe
5
Basic Ada
It will help to be prepared to spot a number of significant features of Ada that are important
for learning its syntax and semantics.
There is a comb format in all the control structures and module structures. See the following
examples for the comb format. You don't have to understand what the examples do yet -
just look for the similarities in layout.
declare
declarations
begin
statements
exception
handlers
end;
6
Things to look out for
exception
handlers
end P;
package P is
declarations
private
declarations
end P;
generic
declarations
package P is
declarations
private
declarations
end P;
generic
declarations
procedure P (parameters : in out type);
Note that semicolons consistently terminate statements and declarations; the empty line (or
a semicolon alone) is not a valid statement: the null statement is
null;
There is an important distinction between type and subtype: a type is given by a set of
values and their operations. A subtype is given by a type, and a constraint that limits the
set of values. Values are always of a type. Objects (constants and variables) are of a subtype.
This generalizes, clarifies and systematizes a relationship, e.g. between Integer and 1..100,
that is handled ad hoc in the semantics of Pascal8 .
8 http://en.wikipedia.org/wiki/Pascal%20programming%20language
7
Basic Ada
Loosely speaking, objects must be of a constrained type, but formal parameters may be of
an unconstrained type (they adopt the constraint of any corresponding actual parameter).
This solves the problem of array parameters in Pascal (among other things).
Where values in Pascal9 or C10 must be static (e.g. the subscript bounds of an array) they
may be dynamic in Ada. However, static expressions are required in certain cases where
dynamic evaluation would not permit a reasonable implementation (e.g. in setting the
number of digits of precision of a floating point type).
Ada consistently supports a separation of interface and mechanism. You can see this in the
format of a package11 , which separates its declaration from its body; and in the concept of
a private type, whose representation in terms of Ada data structures is inaccessible outside
the scope containing its definition.
Most Ada experts lurk on the Usenet newsgroups12 comp.lang.ada (English) and
fr.comp.lang.ada (French); they are accessible either with a newsreader13 or through one of
the many web interfaces. This is the place for all questions related to Ada.
People on these newsgroups are willing to help but will not do students' homework for them;
they will not post complete answers to assignments. Instead, they will provide guidance for
students to find their own answers.
For more online resources, see the External links14 section in this wikibook's introduction.
1.5 Notes
9 http://en.wikipedia.org/wiki/Pascal%20programming%20language
10 http://en.wikipedia.org/wiki/C%20programming%20language
11 Chapter 17 on page 133
12 http://en.wikipedia.org/wiki/Newsgroup
13 http://en.wikipedia.org/wiki/News_client
14 http://en.wikibooks.org/wiki/Ada%20Programming%23External%20links
8
2 Installing
Ada compilers1 are available from several vendors, on a variety of host and target platforms.
The Ada Resource Association2 maintains a list of available compilers3 .
Below is an alphabetical list of available compilers with additional comments.
SofCheck4 produces an Ada 95 front-end that can be plugged into a code generating back-end
to produce a full compiler. This front-end is offered for licensing to compiler vendors.
Based on this front-end, SofCheck offers:
• AdaMagic, an Ada-to-C translator
• AppletMagic, an Ada-to-Java5 bytecode compiler
Commercial; proprietary.
Green Hills Software sells development environments for multiple languages and multiple
targets (including DSP6 s), primarily to embedded software developers.
1 http://en.wikipedia.org/wiki/Compiler
2 http://www.adaic.com
3 http://www.adaic.com/compilers/comp-tool.html
4 http://www.sofcheck.com/
5 http://en.wikibooks.org/wiki/Ada_Programming%2FPlatform%2FVM%2FJava
6 http://en.wikipedia.org/wiki/Digital%20signal%20processor
9
Installing
Support Commercial
Add-ons included IDE, debugger, TimeMachine, integration with
various version control systems, source browsers,
other utilities
GHS claims to make great efforts to ensure that their compilers produce the most efficient
code and often cites the EEMBC7 benchmark results as evidence, since many of the results
published by chip manufacturers use GHS compilers to show their silicon in the best light,
although these benchmarks are not Ada specific.
GHS has no publicly announced plans to support the new Ada standard published in 2007
but they do continue to actively market and develop their existing Ada products.
DEC Ada is an Ada 83 compiler for OpenVMS8 . While “DEC Ada” is probably the name
most users know, the compiler is now called “ HP Ada9 ”. It had previously been known also
by names of "VAX Ada" and "Compaq Ada".
• Ada for OpenVMS Alpha Installation Guide10 (PDF)
• Ada for OpenVMS VAX Installation Guide11 (PDF)
2.4 GNAT, the GNU Ada Compiler from AdaCore and the
Free Software Foundation
GNAT12 is the free GNU Ada compiler, which is part of the GNU Compiler Collection13 .
It is the only Ada compiler that supports all of the optional annexes of the language
standard. The original authors formed the company AdaCore14 to offer professional support,
consulting, training and custom development services. It is thus possible to obtain GNAT
from many different sources, detailed below.
GNAT is always licensed under the terms of the GNU General Public License15 .
However, the run-time library uses either the GPL16 , or the GNAT Modified GPL17 ,
depending on where you obtain it.
7 http://www.eembc.com
8 http://en.wikipedia.org/wiki/OpenVMS
9 http://h71000.www7.hp.com/commercial/ada/ada_index.html
10 http://h71000.www7.hp.com/commercial/ada/ada_avms_ig.pdf
11 http://h71000.www7.hp.com/commercial/ada/ada_vvms_ig.pdf
12 http://en.wikipedia.org/wiki/GNAT
13 http://en.wikipedia.org/wiki/GNU_Compiler_Collection
14 http://www.adacore.com
15 http://en.wikipedia.org/wiki/GNU%20General%20Public%20License
16 http://en.wikipedia.org/wiki/GNU%20General%20Public%20License
17 http://en.wikipedia.org/wiki/GNAT%20Modified%20General%20Public%20License
10
GNAT, the GNU Ada Compiler from AdaCore and the Free Software Foundation
This is a source and binary release from AdaCore, intended for use by Free Software
developers only. If you want to distribute your binary programs linked with the GPL
run-time library, then you must do so under terms compatible with the GNU General Public
License.
As of GNAT GPL Edition 2011:
Languages supported Ada 83, Ada 95, Ada 2005, Ada 2012, C, C++
License for the run-time pure GPL
library
Native platforms GNU/Linux on i386 and x86_64; Microsoft Win-
dows on i386; Microsoft .NET on i386; Mac OS X
(Darwin, x86_64); Solaris on SPARC.
Cross platforms AVR, hosted on Windows; Java VM, hosted on
Windows; Mindstorms NXT, hosted on Windows
Compiler back-end GCC 4.5.3
Available from http://libre.adacore.com/ (requires free regis-
tration)
Support None
Add-ons included GDB, GNATbench (Eclipse plug-in), GPS in
source and binary form; many more in source-only
form.
With these releases of GNAT, you can distribute your programs in binary form under
licensing terms of your own choosing; you are not bound by the GPL.
18 http://en.wikipedia.org/wiki/Ada%20Semantic%20Interface%20Specification
19 http://en.wikibooks.org/wiki/Ada%20Programming%2FPlatform%2FPOSIX
11
Installing
GNAT 3.15p
This is the last public release of GNAT from AdaCore that uses the GNAT Modified General
Public License20 .
GNAT 3.15p has passed the Ada Conformity Assessment Test Suite21 (ACATS22 ). It was
released in October 2002.
The binary distribution from AdaCore also contains an Ada-aware version of the GNU
Debugger (GDB23 ), and a graphical front-end to GDB called the GNU Visual Debugger
(GVD).
GNAT Pro
Languages supported Ada 83, Ada 95, Ada 2005, Ada 2012, C, and
optionally C++
License for the run-time GNAT-modified GPL
library
Native platforms many, see http://www.adacore.com/home/
products/gnatpro/supported_platforms/
Cross platforms many, see http://www.adacore.com/home/
products/gnatpro/supported_platforms/;
even more on request
20 http://en.wikipedia.org/wiki/GNAT%20Modified%20General%20Public%20License
21 http://en.wikipedia.org/wiki/ISO%2018009
22 http://en.wiktionary.org/wiki/ACATS
23 http://en.wikipedia.org/wiki/GDB
12
GNAT, the GNU Ada Compiler from AdaCore and the Free Software Foundation
GCC
GNAT has been part of the Free Software Foundation24 's GCC25 since October 2001.
The Free Software Foundation does not distribute binaries, only sources. Its licensing of
the run-time library for Ada (and other languages) allows the development of proprietary
software without necessarily imposing the terms of the GPL26 .
Most GNU/Linux distributions and several distributions for other platforms include prebuilt
binaries; see below.
For technical reasons, we recommend against using the Ada compilers included in GCC 3.1,
3.2, 3.3 and 4.0. Instead, we recommend using GCC 3.4, 4.1 or later, or one of the releases
from AdaCore27 (3.15p, GPL Edition or Pro).
Since October 2003, AdaCore merge most of their changes from GNAT Pro into GCC during
Stage 128 ; this happens once for each major release. Since GCC 3.4, AdaCore has gradually
added support for revised language standards, first Ada 2005 and now Ada 2012.
GCC version 4.4 switched to version 3 of the GNU General Public License29 and grants
a Runtime Library Exception30 similar in spirit to the GNAT Modified General Public
License31 used in all previous versions. This Runtime Library Exception applies to run-time
libraries for all languages, not just Ada.
As of GCC 4.7, released on 2012-03-22:
Languages supported Ada 83, Ada 95, Ada 2005, parts of Ada 2012, C,
C++, Fortran 95, Java, Objective-C, Objective-
C++ (and others)
License for the run-time GPL version 332 with Runtime Library Excep-
library tion33
Native platforms none (source only)
24 http://www.fsf.org/
25 http://gcc.gnu.org/
26 http://en.wikipedia.org/wiki/GNU%20General%20Public%20License
27 http://www.adacore.com
28 http://gcc.gnu.org/develop.html#stage1
29 http://www.gnu.org/licenses/gpl.html
30 http://www.gnu.org/licenses/gcc-exception.html
31 http://en.wikipedia.org/wiki/GNAT%20Modified%20General%20Public%20License
32 http://www.gnu.org/licenses/gpl.html
33 http://www.gnu.org/licenses/gcc-exception.html
13
Installing
The GNU Ada Project34 provides source and binary packages of various GNAT versions for
several operating systems, and, importantly, the scripts used to create the packages. This
may be helpful if you plan to port the compiler to another platform or create a cross-compiler;
there are instructions for building your own GNAT compiler for GNU/Linux35 and Mac
OS X36 users.
Both GPL37 and GMGPL38 or GCC Runtime Library Exception39 versions of GNAT are
available.
Languages supported Ada 83, Ada 95, Ada 2005, C. (Some distributions
also support Ada 2012, Fortran 90, Java, Objective C
and Objective C++)
License for the run-time pure, GNAT-modified GPL, or GCC Runtime
library Library Exception
Native platforms Fedora Core 4 and 5, MS-DOS, OS/2, Solaris 10,
SuSE 10, MacOS X, (more?)
Cross platforms none
Compiler back-end GCC 2.8.1, 3.4, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6
(various binary packages)
Available from Sourceforge40
Support Volunteer; public bug database
Add-ons included AdaBrowse, ASIS, Booch Components, Charles,
GPS, GtkAda (more?)
This compiler is historical as it has now been merged into GNAT GPL Edition41 and GNAT
Pro42 .
34 http://gnuada.sourceforge.net
35 http://ada.krischik.com/index.php/Articles/CompileGNAT
36 http://forward-in-code.blogspot.com/2011/11/building-gcc-again.html
37 http://en.wikipedia.org/wiki/GNU%20General%20Public%20License
38 http://en.wikipedia.org/wiki/GNAT%20Modified%20General%20Public%20License
39 http://www.gnu.org/licenses/gcc-exception.html
40 http://sourceforge.net/projects/gnuada/files/
41 Chapter 2.4.1 on page 11
42 Chapter 2.4.2 on page 12
14
GNAT, the GNU Ada Compiler from AdaCore and the Free Software Foundation
A# is a port of Ada to the .NET Platform43 . A# was originally developed at the Department
of Computer Science at the United States Air Force Academy which distribute A# as a
service to the Ada community under the terms of the GNU general public license. A#
integrates well with Microsoft Visual Studio 2005, AdaGIDE and the RAPID open-source
GUI Design tool. As of 2006-06-06:
Rolf Ebert and others provide a version of GNAT configured as a cross-compiler to various
AVR microcontrollers44 , as well as an experimental Ada run-time library suitable for use on
the microcontrollers. As of Version 1.1.0 (2010-02-25):
The Real-Time Research Group of the Technical University of Madrid (UPM, Universidad
Politécnica de Madrid) wrote a Ravenscar45 -compliant real-time kernel for execution on
LEON processors46 and a modified run-time library. They also provide a GNAT cross-
compiler. As of version 2.0.1:
43 http://www.microsoft.com/net/
44 http://en.wikipedia.org/wiki/Atmel_AVR
45 http://en.wikipedia.org/wiki/Ravenscar%20profile
46 http://en.wikipedia.org/wiki/LEON
15
Installing
GNAT for Macintosh47 provides both FSF (GMGPL) and AdaCore (GPL) versions of
GNAT48 with Xcode49 and Carbon50 integration and bindings.
Note that this site was last updated for GCC 4.3 and Mac OS X Leopard (both PowerPC
and Intel-based). Aside from the work on integration with Apple’s Carbon graphical user
interface and with Xcode 3.1 it may be preferable to see above51 .
There is also support at MacPorts52 ; the last update (at 25 Nov 2011) was for GCC 4.4.2.
Many distributions contain prebuilt binaries of GCC or various public releases of GNAT
from AdaCore. Quality varies widely between distributions. The list of distributions below
is in alphabetical oder. (Please keep it that way.)
47 http://www.macada.org/
48 http://en.wikipedia.org/wiki/GNAT
49 http://en.wikipedia.org/wiki/Xcode
50 http://en.wikipedia.org/wiki/Carbon%20%28API%29
51 Chapter 2.4.3 on page 14
52 https://trac.macports.org/browser/trunk/dports/lang/gnat-gcc
53 http://sr.sriviere.info/aide/aide.html
16
GNAT, the GNU Ada Compiler from AdaCore and the Free Software Foundation
Blastwave54 has binary packages of GCC 3.4.5 and 4.0.2 with Ada support. The package
names are gcc3ada and gcc4ada respectively.
Languages supported Ada 83, Ada 95, parts of Ada 2005, C, C++,
Fortran 95, Java, Objective-C, Objective-C++
License for the run-time GNAT-modified GPL
library
Native platforms Solaris and OpenSolaris on SPARC
Cross platforms none
Compiler back-end GCC 3.4.5 and 4.0.2 (both available)
Support ?
Available from http://www.blastwave.org/
Add-ons included none (?)
OpenCSW55 has binary packages of GCC 3.4.6 and 4.6.2 with Ada support. The package
names are gcc3ada and gcc4ada respectively.
Languages supported Ada 83, Ada 95, parts of Ada 2005, C, C++,
Fortran 95, Java, Objective-C, Objective-C++
License for the run-time GNAT-modified GPL
library
Native platforms Oracle Solaris and OpenSolaris on SPARC and
x86
Cross platforms none
Compiler back-end GCC 3.4.6 and 4.6.2 (both available)
Support ?
Available from http://www.opencsw.org/
Add-ons included none (?)
54 http://www.blastwave.org
55 http://www.opencsw.org
17
Installing
Cygwin56 , the Linux-like environment for Windows, also contains a version of the GNAT57
compiler. The Cygwin58 version of GNAT59 is older than the MinGW60 version and does
not support DLLs and Multi-Threading (as of 11.2004).
There is a Debian Policy for Ada61 which tries to make Debian the best Ada development and
deployment platform. The development platform includes the compiler and many libraries,
pre-packaged and integrated so as to be easy to use in any program. The deployment platform
is the renowned stable62 distribution, which is suitable for mission-critical workloads and
enjoys long life cycles, typically 3 to 4 years. Because Debian is a binary distribution, it is
possible to deploy non-free, binary-only programs on it while enjoying all the benefits of a
stable platform. Compiler choices are conservative for this reason, and the Policy mandates
that all Ada programs and libraries be compiled with the same version of GNAT. This makes
it possible to use all libraries in the same program. Debian separates run-time libraries from
development packages, so that end users do not have to install the development system just
to run a program.
The GNU Ada compiler can be installed on a Debian system with this command:
This will also give you a list of related packages, which are likely to be useful for an Ada
programmer.
Debian is unique in that it also allows programmers to use some of GNAT's internal
components by means of two libraries:
• libgnatvsn (licensed under GNAT-Modified GPL) and
• libgnatprj (the project manager, licensed under pure GPL).
Debian packages make use of these libraries.
In the table below, the information about the future Debian 7.0 Wheezy is accurate as of
July 2012 but may change.
56 http://www.cygwin.com
57 Chapter 2.4 on page 10
58 http://en.wikipedia.org/wiki/Cygwin
59 http://en.wikipedia.org/wiki/GNAT
60 http://en.wikipedia.org/wiki/MinGW
61 http://people.debian.org/~lbrenta/debian-ada-policy.html
62 http://www.debian.org/releases/stable/
18
3.1 Sarge 4.0 Etch 5.0 Lenny 6.0 Squeeze 7.0 Wheezy
Release date June 2005 April 2007 February 2009 February 2011 2013?
Languages Ada 83, Ada 95, Ada 83, Ada 95, Ada 2005, parts of Ada 2012, C, C++, Fortran 95, Java,
supported C Objective-C, Objective-C++
License for GNAT-modified GPL (both ZCX and SJLJ versions GPL version 3 with Run-time
the run-time starting from 5.0 Lenny) library exception
library
Native plat- 3.1 Sarge 4.0 Etch 5.0 Lenny 6.0 Squeeze 7.0 Wheezy
forms:
alpha yes yes
amd64 yes yes yes yes
armel preliminary yes
armhf yes
hppa yes yes yes
hurd-i386 preliminary
i386 yes yes yes yes yes
ia64 yes yes yes yes
kfreebsd-amd64 yes yes
kfreebsd-i386 yes yes yes yes
mips yes yes yes yes
mipsel yes yes yes yes
powerpc yes yes yes yes yes
ppc64 yes yes yes
s390 yes yes yes yes
sparc yes yes yes yes yes
Cross plat- none
forms
Compiler GCC 2.8.1 GCC 4.1 GCC 4.3 GCC 4.4 GCC 4.6
back-end
Available from http://www.debian.org/
19
GNAT, the GNU Ada Compiler from AdaCore and the Free Software Foundation
20
3.1 Sarge 4.0 Etch 5.0 Lenny 6.0 Squeeze 7.0 Wheezy
Release date June 2005 April 2007 February 2009 February 2011 2013?
Languages Ada 83, Ada 95, Ada 83, Ada 95, Ada 2005, parts of Ada 2012, C, C++, Fortran 95, Java,
Installing
63 http://lists.debian.org/debian-ada
3.1 Sarge 4.0 Etch 5.0 Lenny 6.0 Squeeze 7.0 Wheezy
Release date June 2005 April 2007 February 2009 February 2011 2013?
Languages Ada 83, Ada 95, Ada 83, Ada 95, Ada 2005, parts of Ada 2012, C, C++, Fortran 95, Java,
supported C Objective-C, Objective-C++
License for GNAT-modified GPL (both ZCX and SJLJ versions GPL version 3 with Run-time
the run-time starting from 5.0 Lenny) library exception
library
Native plat- 3.1 Sarge 4.0 Etch 5.0 Lenny 6.0 Squeeze 7.0 Wheezy
forms:
GDB 5.3 6.4 6.8 7.0.1 7.4.1
GLADE 3.15p 2006 (see PolyORB)
GMPAda 0.0.20091124 0.0.20120331
GNADE 1.5.1 1.6.1 1.6.1 1.6.2 1.6.2
GNAT Checker 1999-05-19 (superseded by AdaControl)
GPRBuild 1.3.0w 2011
GPS 2.1 4.0.1 4.0.1 4.3 5.0
GtkAda 2.4 2.8.1 2.8.1 2.14.2 2.24.0
Log4Ada 1.0 1.2
Narval 1.10.2
OpenToken 3.0b 3.0b 3.0b 4.0b 4.0b
PC/SC Ada 0.6 0.7.1
PolyORB 2.6 prerelease 2.8 prerelease
PLPlot 5.9.0 5.9.5 5.9.5
Templates 10.0+20060522 11.1 11.5 11.6
Parser
TextTools 2.0.3 2.0.3 2.0.5 2.0.6
XML/Ada 1.0 2.2 3.0 3.2 4.1
XML-EZ-out 1.06 1.06.1
21
GNAT, the GNU Ada Compiler from AdaCore and the Free Software Foundation
Installing
The ADT plugin for Eclipse (see section ObjectAda from Aonix64 ) can be used with GNAT
as packaged for Debian Etch. Specify "/usr" as the toolchain path.
FreeBSD
FreeBSD70 's ports collection71 contains GNAT GPL 2006 Edition (package gnat-2006),
GNAT 3.15p, GCC 4.1, 4.2 and 4.3 with support for Ada. The usual way to install a package
on FreeBSD is to compile it from source; not all add-ons are compatible with all versions of
GNAT provided.
You can also use the Debian packages described above in a jail, thanks to Debian GNU/k-
FreeBSD.
As of 2008-11-10:
22
GNAT, the GNU Ada Compiler from AdaCore and the Free Software Foundation
Gentoo GNU/Linux
The GNU Ada compiler can be installed on a Gentoo system using emerge:
emerge dev-lang/gnat
Mandriva Linux
The GNU Ada compiler can be installed on a Mandriva system with this command:
urpmi gnat
MinGW — Minimalist GNU for Windows73 contains a version of the GNAT compiler.
The current version of MinGW (5.1.6) contains gcc-4.5.0. This includes a fully functional
GNAT compiler. If the automatic downloader does not work correctly you can download
the compiler directly: pick gcc-4.5.0-1 from MinGW/BaseSystem/GCC/Version4/
72 http://es.znurt.org/dev-ada
73 http://mingw.sourceforge.net
23
Installing
old instructions
The following list should help you with the installation. (I may have forgotten something —
but this is wiki, just add to the list)
1. Install MinGW-3.1.0-1.exe
a) extract binutils-2.15.91-20040904-1.tar.gz
b) extract mingw-runtime-3.5.tar.gz
c) extract gcc-core-3.4.2-20040916-1.tar.gz
d) extract gcc-ada-3.4.2-20040916-1.tar.gz
e) extract gcc-g++-3.4.2-20040916-1.tar.gz (Optional)
f) extract gcc-g77-3.4.2-20040916-1.tar.gz (Optional)
g) extract gcc-java-3.4.2-20040916-1.tar.gz (Optional)
h) extract gcc-objc-3.4.2-20040916-1.tar.gz (Optional)
i) extract w32api-3.1.tar.gz
2. Install mingw32-make-3.80.0-3.exe (Optional)
3. Install gdb-5.2.1-1.exe (Optional)
4. Install MSYS-1.0.10.exe (Optional)
5. Install msysDTK-1.0.1.exe (Optional)
a) extract msys-automake-1.8.2.tar.bz2 (Optional)
b) extract msys-autoconf-2.59.tar.bz2 (Optional)
c) extract msys-libtool-1.5.tar.bz2 (Optional)
I have made good experience in using D:\MinGW as target directory for all installations
and extractions.
Also noteworthy is that the Windows version for GNAT from Libre is also based on MinGW.
In gcc-3.4.2-release_notes.txt from MinGW site reads: please check that the files in the
/lib/gcc/mingw32/3.4.2/adainclude and adalib directories are flagged as read-only. This
attribute is necessary to prevent them from being deleted when using gnatclean to clean a
project.
So be sure to do this.
SuSE Linux
All versions of SuSE Linux have a GNAT compiler included. SuSE versions 9.2 and higher
also contains ASIS, Florist and GLADE libraries. The following two packages are needed:
gnat
gnat-runtime
gcc46-ada
libada46
For 64 bit system you will need the 32 bit compatibility packages as well:
24
ICC from Irvine Compiler Corporation
gnat-32bit
gnat-runtime-32bit
Ubuntu
Irvine Compiler Corporation75 provides native and cross compilers for various platforms.http:
//www.irvine.com/products.html The compiler and run-time system support development
of certified, safety-critical software.
Commercial, proprietary. No-cost evaluation is possible on request. Royalty-free redistribu-
tion of the run-time system is allowed.
RR Software76 offers native compilers for MS-DOS, Microsoft Windows and various Unix
and Unix-like systems, and a library for Windows GUI programming called CLAW. There
are academic, personal and professional editions, as well as support options.
Commercial but relatively cheap; proprietary.
Concurrent77 offers MAXAda78 , an Ada 95 compiler for Linux/Xeon and PowerPC platforms,
and Ada bindings to POSIX and X/Motif.http://www.ccur.com/pdf/cpb-sw-maxada.pdf
Commercial, proprietary.
25
Installing
Atego79 offers native and cross compilers for various platforms. They come with an IDE,
a debugger, a plug-in for Eclipse and a POSIX binding80 http://www.aonix.com/pdf/
oa-linux.pdf.
On Microsoft Windows and GNU/Linux on i386, Aonix offers two pricing models, at the
customer's option: either a perpetual license fee with optional support, or just the yearly
support fee: For Linux, that's $3000 for a single user or $12,000 for a 5-user service pack.
See the full press release81 .
In addition, they offer "ObjectAda Special Edition": a no-cost evaluation version of ObjectAda
that limits the size of programs that can be compiled with it, but is otherwise fully functional,
with IDE and debugger. Free registration required82 .
A recent contribution by Atego is ADT83 for Eclipse84 . The Ada Development Tools add
Ada language support to the Eclipse open source development platform. ADT can be used
with Aonix compilers, and with GNAT. An open source vendor supported project is outlined
for ADT at Eclipse85 . Codenamed Hibachi and showcased at the Ada Conference UK 2007
and during Ada-Europe 2007, the project has now been officially created86 .
Commercial, proprietary.
79 http://www.atego.com/
80 http://en.wikibooks.org/wiki/Ada%20Programming%2FPlatform%2FPOSIX
81 http://www.atego.com/pressreleases/pressitem/aonix-shatters-ada-price-barrier-for-linux
82 http://www.atego.com/support/eval-aonix-objectada/
83 http://www.aonix.com/adt.html
84 http://www.eclipse.org
85 http://www.eclipse.org/proposals/adt/
86 http://www.eclipse.org/hibachi/
87 http://www.ocsystems.com/
88 http://www.ocsystems.com/prod_powerada.html
89 http://www.ocsystems.com/prod_legacyada.html
90 Atego acquires IBM Rational Apex Ada Developer product family
91 http://www-306.ibm.com/software/awdtools/developer/ada/
26
Commercial, proprietary.
DDC-I92 offers its SCORE cross-compilers for embedded development. SCORE stands for
Safety-Critical, Object-oriented, Real-time Embedded.
Commercial, proprietary.
XGC compilers are GCC with custom run-time libraries suitable for avionics and space
applications. The run-time kernels are very small and do not support exception propagation
(i.e. you can handle an exception only in the subprogram that raised it).
Commercial but some versions are also offered as free downloads. Free Software.
92 http://www.ddci.com/
93 http://www.swep-eds.com/XD%20Ada/Xd%20ada.htm
27
Installing
2.14 References
References
94 http://en.wikipedia.org/wiki/ERC32
95 http://en.wikipedia.org/wiki/MIL-STD-1750A
96 http://en.wikipedia.org/wiki/Motorola_68000
97 http://en.wikipedia.org/wiki/IA_32
98 http://en.wikipedia.org/wiki/PowerPC
99 http://en.wikipedia.org/wiki/Intel_80186
28
3 Building
Ada programs are usually easier to build than programs written in other languages like C
or C++, which frequently require a makefile. This is because an Ada source file already
specifies the dependencies of its source unit. See the with keyword1 for further details.
Building an Ada program is not defined by the Reference Manual, so this process is absolutely
dependent on the compiler. Usually the compiler kit includes a make tool which compiles a
main program and all its dependencies, and links an executable file.
This list is incomplete. You can help Wikibooks by adding the build information2 for other
compilers.
3.1.1 GNAT
If the file contains a procedure, gnatmake will generate an executable file with the procedure
as main program. Otherwise, e.g. a package, gnatmake will compile the unit and all its
dependencies.
gnatmake can be written as one word gnatmake or two words gnat make. For a full list
of gnat commands just type gnat without any command options. The output will look
something like this:
1 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Fwith
2 http://en.wikibooks.org/w/index.php?title=Ada_Programming/Building&action=edit
3 http://en.wikipedia.org/wiki/GNAT
29
Building
Commands FIND, LIST, PRETTY, STUB and XREF accept project file
switches -vPx, -Pprj and -Xnam=val
For further help on the option just type the command (one word or two words — as you
like) without any command options.
GNAT IDE
The GNAT toolchain comes with an IDE4 called GPS5 . You need to download and install it
separately. The GPS features a graphical user interface6 .
There are also GNAT plugins for Emacs7 ( Ada Mode8 ), KDevelop9 and Vim10 ( Ada
Mode11 ) available.
Both Emacs and Vim Ada-Mode are maintained by The GNU Ada project12 .
Apple's free (gratis) IDE, Xcode, is included with every Macintosh but requires an explicit
installation step from DVD-ROM or CD-ROM. It is also downloadable from http://
developer.apple.com/. Xcode uses the GNU Compiler Collection13 and thus supports
Ada, GDB14 , etc... and also includes myriad tools for optimizing code which are unique to
4 http://en.wikipedia.org/wiki/Integrated%20development%20environment
5 http://en.wikipedia.org/wiki/GNAT%20Programming%20Studio
6 http://en.wikipedia.org/wiki/Graphical%20user%20interface
7 http://en.wikipedia.org/wiki/Emacs
8 http://stephe-leake.org/emacs/ada-mode/emacs-ada-mode.html
9 http://en.wikipedia.org/wiki/KDevelop
10 http://en.wikipedia.org/wiki/Vim%20%28text%20editor%29
11 http://www.vim.org/scripts/script.php?script_id=1609
12 http://gnuada.sourceforge.net
13 http://en.wikipedia.org/wiki/GNU%20Compiler%20Collection
14 http://en.wikipedia.org/wiki/GNU%20Debugger
30
the Macintosh platform. However, GNAT must be installed separately as it is (as of 2008) not
distributed as part of Xcode. Get the binary and/or sources at http://www.macada.org/,
along with numerous tools and bindings including bindings to Apple's Carbon frameworks
which allow the development of complete, "real" Mac programs, all in Ada.
31
Building
3.1.3 ObjectAda
ObjectAda is a set of tools for editing, compiling, navigating and debugging programs
written in Ada. There are various editions of ObjectAda. With some editions you compile
programs for the same platform and operating systems on which you run the tools. These
are called native. With others, you can produce programs for different operating systems
and platforms. One possible platform is the Java virtual machine.
These remarks apply to the native Microsoft Windows edition. You can run the translation
tools either from the IDE or from the command line.
Whether you prefer to work from the IDE, or from the command line, a little bookkeeping is
required. This is done by creating a project. Each project consists of a number of source files,
and a number of settings like search paths for additional Ada libraries and other dependences.
Each project also has at least one target. Typically, there is a debug target, and a release
target. The names of the targets indicate their purpose. At one time you compile for
debugging, typically during development, at other times you compile with different settings,
for example when the program is ready for release. Some (all commercial?) editions of
ObjectAda permit a Java (VM) target.
DEC Ada is an Ada 83 compiler for VMS15 . While “DEC Ada” is probably the name most
users know, the compiler is now called “ HP Ada16 ”. It had previously been known also by
names of "VAX Ada" and "Compaq Ada".
DEC Ada uses a true library management system — so the first thing you need to do is
create and activate a library:
When creating a library you already set some constraints like support for Long_Float or
the available memory size. So carefully read
Then next step is to load your Ada sources into the library:
The sources don't need to be perfect at this stage but syntactically correct enough for the
compiler to determine the packages declared and analyze the with statements. Dec Ada
allows you to have more than one package in one source file and you have any filename
15 http://en.wikipedia.org/wiki/OpenVMS
16 http://h71000.www7.hp.com/commercial/ada/ada_index.html
32
convention you like. The purpose of ACS Load is the creation of the dependency tree between
the source files.
Next you compile them:
ACS Compile *
Note that compile take the package name and not the filename. The wildcard * means all
packages loaded. The compiler automatically determines the right order for the compilation
so a make17 tool is not strictly needed.
Last but not least you link your file into an
On large systems you might want to break sources down into several libraries — in which
case you also need
to merge the content of the current library with the library higher up the hierarchy. The
larger libraries should then be created with:
This uses a different directory layout more suitable for large libraries.
Dec Ada comes without an IDE, however the DEC LSE18 as well as the Ada Mode19 of the
Vim text editor20 support DEC Ada.
Once you have downloaded21 our example programs you might wonder how to compile
them.
17 http://en.wikipedia.org/wiki/make%20%28software%29
18 http://en.wikipedia.org/wiki/Language-Sensitive_Editor
19 http://www.vim.org/scripts/script.php?script_id=1609
20 http://en.wikipedia.org/wiki/Vim%20%28text%20editor%29
21 https://sourceforge.net/project/showfiles.php?group_id=124904
33
Building
First you need to extract the sources. Use your favorite zip tool22 to achieve that. On
extraction a directory with the same name as the filename is created. Beware: WinZip might
also create a directory equaling the filename so Windows users need to be careful using the
right option otherwise they end up with wikibook-ada-1_2_0.src\wikibook-ada-1_2_0.
Once you extracted the files you will find all sources in wikibook-ada-1_2_0/Source. You
could compile them right there. For your convenience we also provide ready made project
files for the following IDEs (If you find a directory for an IDEs not named it might be in the
making and not actually work).
3.2.1 GNAT
You will find multi-target GNAT Project files and a multi-make Makefile file in wikibook-
ada-2_0_0/GNAT. For i686 Linux and Windows you can compile any demo using:
gps -P project_file
For other target platform it is a bit more difficult since you need to tell the project files
which target you want to create. The following options can be used:
style ("Debug", "Release")
you can define if you like a debug or release version so you can compare how the options
affect size and speed.
os ("Linux", "OS2", "Windows_NT", "VMS")
choose your operating system. Since there is no Ada 2005 available for OS/2 don't expect
all examples to compile.
target ("i686", "x86_64", "AXP")
choose your CPU — "i68623 " is any form of 32bit Intel or AMD CPU, "x86_6424 " is an 64
bit Intel or AMD CPU and if you have an "AXP25 " then you know it.
Remember to type all options as they are shown. To compile a debug version on x86-64
Linux you type:
22 http://en.wikipedia.org/wiki/ZIP%20%28file%20format%29
23 http://en.wikipedia.org/wiki/x86
24 http://en.wikipedia.org/wiki/x86-64
25 http://en.wikipedia.org/wiki/DEC%20Alpha
34
As said in the beginning there is also a makefile available that will automatically determine
the target used. So if you have a GNU make you can save yourself a lot of typing by using:
make project
or even use
make all
APEX uses the subsystem and view directory structure, so you will have to create those first
and copy the source files into the view. After creating a view using the architecture model
of your choice, use the menu option "Compile -> Maintenance -> Import Text Files". In the
Import Text Files dialog, add "wikibook-ada-2_0_0/Source/*.ad?" to select the Ada source
files from the directory you originally extracted to. Apex uses the file extensions .1.ada for
specs and .2.ada for bodies — don't worry, the import text files command will change these
automatically.
To link an example, select its main subprogram in the directory viewer and click the link
button in the toolbar, or "Compile -> Link" from the menu. Double-click the executable to
run it. You can use the shift-key modifier to bypass the link or run dialog.
3.2.3 ObjectAda
ObjectAda command-line
The following describes using the ObjectAda tools for Windows in a console window.
Before you can use the ObjectAda tools from the command line, make sure the PATH
environment variable lists the directory containing the ObjectAda tools. Something like
set path=%path%;P:\Programs\Aonix\ObjectAda\bin
To build an executable from this source file, follow these steps (assuming the current directory
is a fresh one and contains the above mentioned source file):
35
Building
This makes your sources known to the ObjectAda tools. Have a look at the file UNIT.MAP
created by adareg in the current directory if you like seeing what is happening under the
hood.
• Compile the source file:
X:\some\directory> adacomp hello_world_1.adb
Front end of hello_world_1.adb succeeded with no errors.
Notice that you specify the name of the main unit as argument to adabuild, not the name
of the source file. In this case, it is Hello_World_1 as in
procedure Hello_World_1 is
More information about the tools can be found in the user guide Using the command line
interface, installed with the ObjectAda tools.
26 http://gcc.gnu.org/onlinedocs/gcc-4.0.1/gnat_ugn_unw/
27 http://h71000.www7.hp.com/commercial/ada/ada_dap.pdf
28 http://h71000.www7.hp.com/commercial/ada/ada_lrm.pdf
29 http://h71000.www7.hp.com/commercial/ada/ada_rtr.pdf
36
4 Control Statements
4.1 Conditionals
Conditionals
Conditional clauses are blocks of code that will only execute if a particular expression (the
condition) is true1 .
4.1.1 if-else
The if-else statement is the simplest of the conditional statements. They are also called
branches, as when the program arrives at an if statement during its execution, control will
"branch" off into one of two or more "directions". An if-else statement is generally in the
following form:
if condition then
statement;
else
other statement;
end if;
If the original condition is met, then all the code within the first statement is executed.
The optional else section specifies an alternative statement that will be executed if the
condition is false. Exact syntax will vary between programming languages, but the majority
of programming languages (especially procedural2 and structured3 languages) will have some
form of if-else conditional statement built-in. The if-else statement can usually be extended
to the following form:
if condition then
statement;
elsif condition then
other statement;
elsif condition then
other statement;
...
else
another statement;
end if;
1 http://en.wikipedia.org/wiki/Truth%20function
2 http://en.wikibooks.org/wiki/Computer%20Programming%2FProcedural%20programming
3 http://en.wikibooks.org/wiki/Computer%20Programming%2FStructured%20programming
37
Control Statements
Only one statement in the entire block will be executed. This statement will be the first one
with a condition which evaluates to be true. The concept of an if-else-if structure is easier
to understand with the aid of an example:
with Ada ;
use Ada ;
...
type Degrees is new Float range -273.15 .. Float'Last;
...
Temperature : Degrees;
...
if Temperature >= 40.0 then
Put_Line ("Wow!");
Put_Line ("It's extremely hot");
elsif Temperature >= 30.0 then
Put_Line ("It's hot");
elsif Temperature >= 20.0 then
Put_Line ("It's warm");
elsif Temperature >= 10.0 then
Put_Line ("It's cool");
elsif Temperature >= 0.0 then
Put_Line ("It's cold");
else
Put_Line ("It's freezing");
end if;
When this program executes, the computer will check all conditions in order until one of
them matches its concept of truth. As soon as this occurs, the program will execute the
statement immediately following the condition and continue on, without checking any other
condition for truth. For this reason, when you are trying to optimize4 a program, it is a
good idea to sort your if-else conditions in descending probability5 . This will ensure that in
the most common scenarios, the computer has to do less work, as it will most likely only
have to check one or two "branches" before it finds the statement which it should execute.
However, when writing programs for the first time, try not to think about this too much
lest you find yourself undertaking premature optimization6 .
Having said all that, you should be aware that an optimizing compiler7 might rearrange
your if statement at will when the statement in question is free from side effects8 . Among
other techniques optimizing compilers might even apply jump tables9 and binary searches10 .
In Ada, conditional statements with more than one conditional do not use short-circuit
evaluation by default. In order to mimic C/C++'s short-circuit evaluation, use and then
or or else between the conditions.
4 http://en.wikipedia.org/wiki/Optimization_%2528computer_science%2529
5 http://en.wikibooks.org/wiki/Probability%2FIntroduction
6 http://en.wikipedia.org/wiki/Premature_optimization%23When_to_optimize
7 http://en.wikipedia.org/wiki/Optimizing_compiler
8 http://en.wikipedia.org/wiki/Side-effect_%28computer_science%29
9 http://en.wikipedia.org/wiki/Jump_table
10 http://en.wikipedia.org/wiki/Binary_search
38
4.1.3 case
Often it is necessary to compare one specific variable against several constant expressions.
For this kind of conditional expression the case statement exists. For example:
case X is
when 1 =>
Walk_The_Dog;
when 5 =>
Launch_Nuke;
when 8 | 10 =>
Sell_All_Stock;
Self_Destruct;
end case;
4.2 Unconditionals
Unconditionals
Unconditionals let you change the flow of your program without a condition. You should be
careful when using unconditionals. Often they make programs difficult to understand. Read
Isn't goto evil?11 for more information.
4.2.1 return
return;
For functions:
39
Control Statements
return Value;
4.2.2 goto
Dont_Do_Something;
<< Label>>
...
One often hears that goto is evil and one should avoid using goto. But it is often overlooked
that any return which is not the last statement inside a procedure or function is also an
unconditional statement — a goto in disguise. There is an important difference though: a
return is a forward only use of goto. Exceptions are also a type of goto statement; worse,
they need not specify where they are going to!
Therefore if you have functions and procedures with more than one return statement you
can just as well use goto. When it comes down to readability the following two samples are
almost the same:
procedure Use_Return is
begin
Do_Something;
if Test then
return;
end if;
Do_Something_Else;
return;
end Use_Return;
procedure Use_Goto is
begin
Do_Something;
if Test then
goto Exit_Use_Goto;
end if;
Do_Something_Else;
<< Exit_Use_Goto>>
return;
end Use_Goto;
Because the use of a goto needs the declaration of a label, the goto is in fact twice as readable
than the use of return. So if readability is your concern and not a strict "don't use goto"
40
programming rule then you should rather use goto than multiple returns. Best, of course, is
the structured approach where neither goto nor multiple returns are needed:
procedure Use_If is
begin
Do_Something;
Do_Something_Else;
end if;
return;
end Use_If;
4.3 Loops
Loops
Loops allow you to have a set of statements repeated over and over again.
The endless loop is a loop which never ends and the statements inside are repeated forever.
Never is meant as a relative term here — if the computer is switched off then even endless
loops will end very abruptly.
Endless_Loop :
loop
Do_Something;
The loop name (in this case, "Endless_Loop") is an optional feature of Ada. Naming loops
is nice for readability but not strictly needed. Loop names are useful though if the program
should jump out of an inner loop, see below.
This loop has a condition at the beginning. The statements are repeated as long as the
condition is met. If the condition is not met at the very beginning then the statements
inside the loop are never executed.
While_Loop :
while X <= 5 loop
X := Calculate_Something;
41
Control Statements
This loop has a condition at the end and the statements are repeated until the condition is
met. Since the check is at the end the statements are at least executed once.
Until_Loop :
loop
X := Calculate_Something;
Sometimes you need to first make a calculation and exit the loop when a certain criterion is
met. However when the criterion is not met there is something else to be done. Hence you
need a loop where the exit condition is in the middle.
Exit_Loop :
loop
X := Calculate_Something;
Do_Something (X);
In Ada the exit condition can be combined with any other loop statement as well. You can
also have more than one exit statement. You can also exit a named outer loop if you have
several loops inside each other.
Quite often one needs a loop where a specific variable is counted from a given start value up
or down to a specific end value. You could use the while12 loop here — but since this is a
very common loop there is an easier syntax available.
For_Loop :
for I in Integer range 1 .. 10 loop
Do_Something (I)
You don't have to declare both type and range as seen in the example. If you leave out the
type then the compiler will determine the type by context and leave out the range then the
loop will iterate over every valid value for the type given.
42
As always with Ada: when "determine by context" gives two or more possible options then
an error will be displayed and then you have to name the type to be used. Ada will only do
"guess-works" when it is safe to do so.
Another very common situation is the need for a loop which iterates over every element of
an array. The following sample code shows you how to achieve this:
Array_Loop :
for I in X'Range loop
X (I) := Get_Next_Element;
With X being an array. Note: This syntax is mostly used on arrays — hence the name —
but will also work with other types when a full iteration is needed.
Unlike other loop counters, the loop counter i, in the for loop statement the value cannot be
changed. The following is illegal.
for i in 1 .. 10 loop
i := i + 1;
end loop;
Also the declaration of the loop counter ceases after the body of the loop.
Working Demo
The following Demo shows how to iterate over every element of an integer type.
File: range_1.adb
with Ada ;
procedure Range_1 is
type Range_Type is range -5 .. 10;
begin
for A in Range_Type loop
I_IO.Put (Item => A,
Width => 3,
Base => 10);
43
Control Statements
end loop;
end Range_1;
4.4.1 Wikibook
• Ada Programming13
13 http://en.wikibooks.org/wiki/Ada%20Programming
44
5 Type System
Ada's type system allows the programmer to construct powerful abstractions that represent
the real world, and to provide valuable information to the compiler, so that the compiler can
find many logic or design errors before they become bugs. It is at the heart of the language,
and good Ada programmers learn to use it to great advantage. Four principles govern the
type system:
• Strong typing: types are incompatible with one another, so it is not possible to mix
apples and oranges. There are, however, ways to convert between types.
• Static typing: type checked while compiling, this allows type errors to be found earlier.
• Abstraction: types represent the real world or the problem at hand; not how the
computer represents the data internally. There are ways to specify exactly how a type
must be represented at the bit level, but we will defer that discussion to another chapter.
• Name equivalence, as opposed to structural equivalence used in most other languages.
Two types are compatible if and only if they have the same name; not if they just happen
to have the same size or bit representation. You can thus declare two integer types with
the same ranges that are totally incompatible, or two record types with exactly the same
components, but which are incompatible.
Types are incompatible with one another. However, each type can have any number of
subtypes, which are compatible with one another, and with their base type.
There are several predefined types, but most programmers prefer to define their own,
application-specific types. Nevertheless, these predefined types are very useful as interfaces
between libraries developed independently. The predefined library, obviously, uses these
types too.
These types are predefined in the Standard package:
Integer
This type covers at least the range −215 +1 .. +215 −1 (RM 3.5.4 (21) ˆ{http://www.adaic.
org/resources/add_content/standards/05rm/html/RM-3-5-4.html} ). The Standard
also defines Natural and Positive subtypes of this type.
Float
There is only a very weak implementation requirement on this type (RM 3.5.7 (14) ˆ{http:
//www.adaic.org/resources/add_content/standards/05rm/html/RM-3-5-7.html} );
45
Type System
most of the time you would define your own floating-point types, and specify your precision
and range requirements.
Duration
A fixed point type1 used for timing. It represents a period of time in sec-
onds (RM A.1 (43) ˆ{http://www.adaic.org/resources/add_content/standards/
05rm/html/RM-A-1.html} ).
Character
A special form of Enumerations2 . There are three predefined kinds of character types:
8-bit characters (called Character), 16-bit characters (called Wide_Character), and 32-bit
characters (Wide_Wide_Character). Character has been present since the first version of
the language (Ada 833 ), Wide_Character was added in Ada 954 , while the type Wide_-
Wide_Character is available with Ada 20055 .
String6
Three indefinite array types7 , of Character, Wide_Character, and Wide_Wide_Character
respectively. The standard library contains packages for handling strings in three variants:
fixed length (Ada ), with varying length below a certain upper bound (Ada ), and unbounded
length (Ada ). Each of these packages has a Wide_and a Wide_Wide_variant.
Boolean
A Boolean in Ada is an Enumeration8 of False and True with special semantics.
Packages System and System predefine some types which are primarily useful for low-level
programming and interfacing to hardware.
System.Address
An address in memory.
System.Storage_Elements.Storage_Offset
An offset, which can be added to an address to obtain a new address. You can also
subtract one address from another to get the offset between them. Together, Address,
Storage_Offset and their associated subprograms provide for address arithmetic.
System.Storage_Elements.Storage_Count
A subtype of Storage_Offset which cannot be negative, and represents the memory size of
a data structure (similar to C's size_t).
System.Storage_Elements.Storage_Element
1 Chapter 10 on page 79
2 Chapter 8 on page 73
3 http://en.wikibooks.org/wiki/Ada%20Programming%2FAda%2083
4 http://en.wikibooks.org/wiki/Ada%20Programming%2FAda%2095
5 Chapter 23 on page 219
6 Chapter 15 on page 119
7 Chapter 11 on page 83
8 Chapter 8 on page 73
46
In most computers, this is a byte. Formally, it is the smallest unit of memory that has an
address.
System.Storage_Elements.Storage_Array
An array of Storage_Elements without any meaning, useful when doing raw memory access.
Types are organized hierarchically. A type inherits properties from types above it in the
hierarchy. For example, all scalar types (integer, enumeration, modular, fixed-point and
floating-point types) have operators9 "<", ">" and arithmetic operators defined for them, and
all discrete types can serve as array indexes.
47
Type System
Here is a broad overview of each category of types; please follow the links for detailed
explanations. Inside parenthesis there are equivalences in C and Pascal for readers familiar
with those languages.
Signed Integers10 (int, INTEGER)
Signed Integers are defined via the range11 of values needed.
Unsigned Integers12 (unsigned, CARDINAL)
Unsigned Integers are called Modular Types13 . Apart from being unsigned they also have
wrap-around functionality.
Enumerations14 (enum, char, bool, BOOLEAN)
Ada Enumeration15 types are a separate type family.
Floating point16 (float, double, REAL)
Floating point types are defined by the digits17 needed, the relative error bound.
Ordinary and Decimal Fixed Point18 (DECIMAL)
Fixed point types are defined by their delta19 , the absolute error bound.
Arrays20 ( [ ], ARRAY [ ] OF, STRING )
Arrays with both compile-time and run-time determined size are supported.
Record21 (struct, class, RECORD OF)
A record is a composite type22 that groups one or more fields.
Access23 (*, ˆ, POINTER TO)
Ada's Access24 types may be more than just a simple memory address.
Task & Protected25 (no equivalence in C or Pascal)
Task and Protected types allow the control of concurrency
Interfaces26 (no equivalence in C or Pascal)
10 Chapter 6 on page 69
11 Chapter 6 on page 69
12 Chapter 7 on page 71
13 Chapter 7 on page 71
14 Chapter 8 on page 73
15 Chapter 8 on page 73
16 Chapter 9 on page 77
17 Chapter 9 on page 77
18 Chapter 10 on page 79
19 Chapter 10 on page 79
20 Chapter 11 on page 83
21 Chapter 12 on page 91
22 http://en.wikibooks.org/wiki/Ada%20Programming%2FTypes%23List%20of%20types
23 Chapter 13 on page 99
24 Chapter 13 on page 99
25 Chapter 21 on page 173
26 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Finterface
48
New in Ada 2005, these types are similar to the Java interfaces.
Operations of specific types are non-dispatching, those on class-wide types are dispatching.
New types can be declared by deriving from specific types; primitive operations are inherited
by derivation. You cannot derive from class-wide types.
Constrained vs. Unconstrained
Declaring an unconstrained object is only possible if a default value is given in the type
declaration above. The language does not specify how such objects are allocated. GNAT
allocates the maximum size, so that size changes that might occur with discriminant changes
present no problem. Another possibility is implicit dynamic allocation on the heap and
deallocation followed be a re-allocation when the size changes.
Definite vs. Indefinite
Definite subtypes allow the declaration of objects without initial value, since objects of
definite subtypes have constraints that are known at creation-time. Object declarations of
indefinite subtypes need an initial value to supply a constraint; they are then constrained by
49
Type System
The Ada language uses types for one more purpose in addition to classifying data + operations.
The type system integrates concurrency (threading, parallelism). Programmers will use
types for expressing the concurrent threads of control of their programs.
The core pieces of this part of the type system, the task types and the protected types
are explained in greater depth in a section on tasking27 .
Limiting a type means disallowing assignment. The “concurrency types” described above
are always limited. Programmers can define their own types to be limited, too, like this:
type T is limited . . .;
(The ellipsis stands for private, or for a record definition, see the corresponding subsection
on this page.) A limited type also doesn't have an equality operator unless the programmer
defines one.
You can learn more in the limited types28 chapter.
50
Defining new types and subtypes
type T is...
followed by the description of the type, as explained in detail in each category of type.
Formally, the above declaration creates a type and its first subtype named T. The type itself,
correctly called the "type of T", is anonymous; the RM refers to it as T (in italics), but often
speaks sloppily about the type T. But this is an academic consideration; for most purposes,
it is sufficient to think of T as a type. For scalar types, there is also a base type called
T'Base, which encompasses all values of T.
For signed integer types, the type of T comprises the (complete) set of mathematical integers.
The base type is a certain hardware type, symmetric around zero (except for possibly one
extra negative value), encompassing all values of T.
As explained above, all types are incompatible; thus:
is illegal, because Integer_1 and Integer_2 are different and incompatible types. It is this
feature which allows the compiler to detect logic errors at compile time, such as adding a
file descriptor to a number of bytes, or a length to a weight. The fact that the two types
have the same range does not make them compatible: this is name equivalence in action,
as opposed to structural equivalence. (Below, we will see how you can convert between
incompatible types; there are strict rules for this.)
You can also create new subtypes of a given type, which will be compatible with each other,
like this:
51
Type System
It is not necessary that the subtype ranges overlap, or be included in one another. The
compiler inserts a run-time range check when you assign A to B; if the value of A, at that
point, happens to be outside the range of Integer_3, the program raises Constraint_Error.
There are a few predefined subtypes which are very useful:
A derived type is a new, full-blown type created from an existing one. Like any other type,
it is incompatible with its parent; however, it inherits the primitive operations defined for
the parent type.
Here both types are discrete; it is mandatory that the range of the derived type be included
in the range of its parent. Contrast this with subtypes. The reason is that the derived type
inherits the primitive operations defined for its parent, and these operations assume the
range of the parent type. Here is an illustration of this feature:
procedure Derived_Types is
package Pak is
type Integer_1 is range 1 .. 10;
procedure P (I: in Integer_1); --primitive operation, assumes 1 .. 10
type Integer_2 is new Integer_1 range 8 .. 10; --must not break P's assumption
--procedure P (I: in Integer_2); inherited P implicitly defined here
end Pak;
use Pak;
A: Integer_1 := 4;
B: Integer_2 := 9;
begin
end Derived_Types;
When we call P (B), the parameter B is converted to Integer_1; this conversion of course
passes since the set of acceptable values for the derived type (here, 8 .. 10) must be included
in that of the parent type (1 .. 10). Then P is called with the converted parameter.
52
Consider however a variant of the example above:
procedure Derived_Types is
package Pak is
type Integer_1 is range 1 .. 10;
procedure P (I: in Integer_1; J: out Integer_1);
type Integer_2 is new Integer_1 range 8 .. 10;
end Pak;
use Pak;
A: Integer_1 := 4; X: Integer_1;
B: Integer_2 := 8; Y: Integer_2;
begin
P (A, X);
P (B, Y);
end Derived_Types;
When P (B, Y) is called, both parameters are converted to Integer_1. Thus the range
check on J (7) in the body of P will pass. However on return parameter Y is converted back
to Integer_2 and the range check on Y will of course fail.
With the above in mind, you will see why in the following program Constraint_Error will
be called at run time.
procedure Derived_Types is
package Pak is
type Integer_1 is range 1 .. 10;
procedure P (I: in Integer_1; J: out Integer_1);
type Integer_2 is new Integer_1'Base range 8 .. 12;
end Pak;
use Pak;
begin
P (B, Y);
end Derived_Types;
53
Type System
Ada supports various categories of subtypes which have different abilities. Here is an overview
in alphabetical order.
A subtype which does not have a name assigned to it. Such a subtype is created with a
variable declaration:
In Ada, all types are anonymous29 and only subtypes may be named30 . For scalar types,
there is a special subtype of the anonymous type, called the base type, which is nameable
with the 'Base attribute. The base type comprises all values of the first subtype. Some
examples:
The base type Int'Base is a hardware type selected by the compiler that comprises
the values of Int. Thus it may have the range -27 .. 27 -1 or -215 .. 215 -1 or any other such type.
Enum'Base is the same as Enum, but Short'Base also holds the literal D.
54
5.6.3 Constrained subtype
A subtype of an indefinite subtype31 that adds constraints. The following example defines a
10 character string sub-type.
type My_Array is array (Integer range <>, Integer range <>) of Some_Type;
Constraints for all indices must be given, the result is necessarily a definite subtype32 .
A definite subtype33 is a subtype whose size is known at compile-time. All subtypes which
are not indefinite subtypes34 are, by definition, definite subtypes35 .
Objects of definite subtypes may be declared without additional constraints.
X is an object of the indefinite (sub)type String. Its constraint is derived implicitly from its
initial value. X may change its value, but not its bounds.
It should be noted that it is not necessary to initialize the object from a literal. You can
also use a function. For example:
31 http://en.wikibooks.org/wiki/ada%20Programming%2FSubtypes%23indefinite_subtype
32 http://en.wikibooks.org/wiki/ada%20Programming%2FSubtypes%23definite_subtype
33 http://en.wikibooks.org/wiki/ada%20Programming%2FSubtypes%23definite_subtype
34 http://en.wikibooks.org/wiki/ada%20Programming%2FSubtypes%23indefinite_subtype
35 http://en.wikibooks.org/wiki/ada%20Programming%2FSubtypes%23definite_subtype
55
Type System
A subtype which has a name assigned to it. “First subtypes” are created with
the keyword type (remember that types are always anonymous, the name in a type
declaration is the name of the first subtype), others with the keyword subtype. For example:
Count_to_Ten is the first subtype of a suitable integer base type. However, if you would
like to use this as an index constraint on String, the following declaration is illegal:
This is because String has Positive as index, which is a subtype of Integer (these declarations
are taken from package Standard):
Now Ten_Characters is the name of that subtype of String which is constrained to Count_-
To_Ten. You see that posing constraints on types versus subtypes has very different
effects.
A subtype of an indefinite subtype that does not add a constraint only introduces a new
name for the original subtype.
56
5.7 Qualified expressions
Qualified expressions
In most cases, the compiler is able to infer the type of an expression; for example:
Here the compiler knows that A is a value of the type Enum. But consider:
procedure Bad is
type Enum_1 is (A, B, C);
procedure P (E : in Enum_1) is... --omitted
type Enum_2 is (A, X, Y, Z);
procedure P (E : in Enum_2) is... --omitted
begin
P (A); --illegal: ambiguous
end Bad;
The compiler cannot choose between the two versions of P; both would be equally valid. To
remove the ambiguity, you use a qualified expression:
P (Enum_1'(A)); --OK
As seen in the following example, this syntax is often used when creating new objects. If
you try to compile the example, it will fail with a compilation error since the compiler will
determine that 256 is not in range of Byte.
File: convert_evaluate_as.adb
with Ada ;
procedure Convert_Evaluate_As is
type Byte is mod 2**8;
type Byte_Ptr is access Byte;
57
Type System
Type conversions
Data do not always come in the format you need them. You must, then, face the task of
converting them. As a true multi-purpose language with a special emphasis on "mission
critical", "system programming" and "safety", Ada has several conversion techniques. The
most difficult part is choosing the right one, so the following list is sorted in order of utility.
You should try the first one first; the last technique is a last resort, to be used if all others
fail. There are also a few related techniques that you might choose instead of actually
converting the data.
Since the most important aspect is not the result of a successful conversion, but how the
system will react to an invalid conversion, all examples also demonstrate faulty conversions.
An explicit type conversion looks much like a function call; it does not use the tick
(apostrophe, ') like the qualified expression does.
Type_Name (Expression)
The compiler first checks that the conversion is legal, and if it is, it inserts a run-time
check at the point of the conversion; hence the name checked conversion. If the conversion
fails, the program raises Constraint_Error. Most compilers are very smart and optimise
away the constraint checks; so, you need not worry about any performance penalty. Some
compilers can also warn that a constraint check will always fail (and optimise the check with
an unconditional raise).
Explicit type conversions are legal:
• between any two numeric types
• between any two subtypes of the same type
• between any two types derived from the same type (note special rules for tagged types)
• between array types under certain conditions (see RM 4.6(24.2/2..24.7/2))
• and nowhere else
(The rules become more complex with class-wide and anonymous access types.)
File: convert_checked.adb
58
with Ada ;
procedure Convert_Checked is
type Short is range -128 .. +127;
type Byte is mod 256;
A : Short := -1;
B : Byte;
begin
B := Byte (A); -- range check will lead to Constraint_Error
T_IO.Put ("A = ");
I_IO.Put (Item => A,
Width => 5,
Base => 10);
T_IO.Put (", B = ");
M_IO.Put (Item => B,
Width => 5,
Base => 10);
end Convert_Checked;
Explicit conversions are possible between any two numeric types: integers, fixed-point and
floating-point types. If one of the types involved is a fixed-point or floating-point type,
the compiler not only checks for the range constraints (thus the code above will raise
Constraint_Error), but also performs any loss of precision necessary.
Example 1: the loss of precision causes the procedure to only ever print "0" or "1", since P /
100 is an integer and is always zero or one.
with Ada.Text_IO;
procedure Naive_Explicit_Conversion is
type Proportion is digits 4 range 0.0 .. 1.0;
type Percentage is range 0 .. 100;
function To_Proportion (P : in Percentage) return Proportion is
begin
return Proportion (P / 100);
end To_Proportion;
begin
Ada.Text_IO.Put_Line (Proportion'Image (To_Proportion (27)));
end Naive_Explicit_Conversion;
with Ada.Text_IO;
procedure Explicit_Conversion is
type Proportion is digits 4 range 0.0 .. 1.0;
type Percentage is range 0 .. 100;
function To_Proportion (P : in Percentage) return Proportion is
type Prop is digits 4 range 0.0 .. 100.0;
begin
return Proportion (Prop (P) / 100.0);
end To_Proportion;
begin
Ada.Text_IO.Put_Line (Proportion'Image (To_Proportion (27)));
end Explicit_Conversion;
59
Type System
You might ask why you should convert between two subtypes of the same type. An example
will illustrate this.
Here, Slice has bounds 1 and 10, whereas X (11 .. 20) has bounds 11 and 20.
Type conversions can be used for packing and unpacking of records or arrays.
P: Packed;
U: Unpacked;
The examples above all revolved around conversions between numeric types; it is possible to
convert between any two numeric types in this way. But what happens between non-numeric
types, e.g. between array types or record types? The answer is two-fold:
• you can convert explicitly between a type and types derived from it, or between types
derived from the same type,
• and that's all. No other conversions are possible.
Why would you want to derive a record type from another record type? Because of
representation clauses. Here we enter the realm of low-level systems programming, which is
not for the faint of heart, nor is it useful for desktop applications. So hold on tight, and
let's dive in.
Suppose you have a record type which uses the default, efficient representation. Now you
want to write this record to a device, which uses a special record format. This special
representation is more compact (uses fewer bits), but is grossly inefficient. You want to
have a layered programming interface: the upper layer, intended for applications, uses
the efficient representation. The lower layer is a device driver that accesses the hardware
directly and uses the inefficient representation.
60
package Device_Driver is
type Size_Type is range 0 .. 64;
type Register is record
A, B : Boolean;
Size : Size_Type;
end record;
The compiler chooses a default, efficient representation for Register. For example, on
a 32-bit machine, it would probably use three 32-bit words, one for A, one for B and
one for Size. This efficient representation is good for applications, but at one point
we want to convert the entire record to just 8 bits, because that's what our hardware requires.
In the above example, the package body declares a derived type with the inefficient, but
compact representation, and converts to and from it.
This illustrates that type conversions can result in a change of representation.
Within object-oriented programming36 you have to distinguish between specific types and
class-wide types.
With specific types, only conversions to ancestors are possible and, of course, are checked.
During the conversion, you do not "drop" any components that are present in the derived
type and not in the parent type; these components are still present, you just don't see them
anymore. This is called a view conversion.
61
Type System
There are no conversions to derived types (where would you get the further components from?);
extension aggregates have to be used instead.
Child_Instance : Child_Type;
This view conversion involves a run-time check to see if Parent_View is indeed a view of an
object of type Child_Type. In the second case, the run-time check accepts objects of type
Child_Type but also any type derived from Child_Type.
View renaming
A renaming declaration does not create any new object and performs no conversion; it
only gives a new name to something that already exists. Performance is optimal since the
renaming is completely done at compile time. We mention it here because it is a common
idiom in object oriented programming37 to rename the result of a view conversion.
Child_Instance : Child_Type;
Parent_View : Parent_Type'Class renames Parent_Type'Class (Child_Instance);
Now, Parent_View is not a new object, but another name for Child_Instance viewed as
the parent, i.e. only the parent components are visible, the further child components are
hidden.
62
5.8.5 Address conversion
Ada's access type38 is not just a memory location (a thin pointer). Depending on imple-
mentation and the access type39 used, the access40 might keep additional information (a fat
pointer). For example GNAT keeps two memory addresses for each access41 to an indefinite
object — one for the data and one for the constraint informations (Size, First, Last).
If you want to convert an access to a simple memory location you can use the package
System . Note however that an address and a fat pointer cannot be converted reversibly
into one another.
The address of an array object is the address of its first component. Thus the bounds get
lost in such a conversion.
A'Address = A(A'First)'Address
One of the great criticisms of Pascal was "there is no escape". The reason was that
sometimes you have to convert the incompatible. For this purpose, Ada has the generic
function Unchecked_Conversion:
generic
type Source (<>) is limited private;
type Target (<>) is limited private;
function Ada (S : Source) return Target;
Unchecked_Conversion will bit-copy the source data and reinterprete them under the target
type without any checks. It is your chore to make sure that the requirements on unchecked
conversion as stated in RM 13.9 ˆ{http://www.adaic.org/resources/add_content/
standards/05rm/html/RM-13-9.html} are fulfilled; if not, the result is implementation
dependent and may even lead to abnormal data. Use the 'Valid attribute after the conversion
to check the validity of the data in problematic cases.
A function call to (an instance of) Unchecked_Conversion will copy the source to the
destination. The compiler may also do a conversion in place (every instance has the
convention Intrinsic).
To use Unchecked_Conversion you need to instantiate the generic.
38 Chapter 13 on page 99
39 Chapter 13 on page 99
40 Chapter 13 on page 99
41 Chapter 13 on page 99
63
Type System
In the example below, you can see how this is done. When run, the example will output "A
= -1, B = 255". No error will be reported, but is this the result you expect?
File: convert_unchecked.adb
with Ada ;
with Ada ;
procedure Convert_Unchecked is
begin
B := Convert (A);
T_IO.Put ("A = ");
I_IO.Put (Item => A,
Width => 5,
Base => 10);
T_IO.Put (", B = ");
M_IO.Put (Item => B,
Width => 5,
Base => 10);
end Convert_Unchecked;
There is of course a range check in the assignment B := Convert (A);. Thus if B were
defined as B: Byte range 0 .. 10;, Constraint_Error would be raised.
5.8.7 Overlays
64
wrong. For example if Source'Size < Target'Size and you assign a value to Target, you
might inadvertently write into memory allocated to a different object.
You have to take care also of implicit initializations of objects of the target type, since they
would overwrite the actual value of the source object. The Import pragma with convention
Ada can be used to prevent this, since it avoids the implicit initialization, RM B.1 ˆ{http:
//www.adaic.org/resources/add_content/standards/05rm/html/RM-B-1.html} .
The example below does the same as the example from "Unchecked Conversion".
File: convert_address_mapping.adb
with Ada ;
procedure Convert_Address_Mapping is
type Short is range -128 .. +127;
type Byte is mod 256;
A : aliased Short;
B : aliased Byte;
begin
A := -1;
T_IO.Put ("A = ");
I_IO.Put (Item => A,
Width => 5,
Base => 10);
T_IO.Put (", B = ");
M_IO.Put (Item => B,
Width => 5,
Base => 10);
end Convert_Address_Mapping;
Just for the record: There is still another method using the pragma and pragma pragmas.
However, since this method completely undermines Ada's visibility and type concepts even
more than overlays, it has no place here in this language introduction and is left to experts.
65
Type System
declares an anonymous type T and its first subtype T (please note the italicization). T
encompasses the complete set of mathematical integers. Static expressions and named
numbers make use of this fact.
All numeric integer literals are of type Universal_Integer. They are converted to the
appropriate specific type where needed. Universal_Integer itself has no operators.
Some examples with static named numbers:
Static expressions are evaluated at compile-time on the appropriate types with no overflow
checks, i.e. mathematically exact (only limited by computer store). The result is then
implicitly converted to Universal_Integer.
The literal 1 in S2 is of type Universal_Integer and implicitly converted to Long_Integer.
S3 implicitly converts the summands to root_integer, performs the calculation and converts
back to Universal_Integer.
S4 is illegal because it mixes two different types. You can however write this as
where the Pos attributes convert the values to Universal_Integer, which are then further
implicitly converted to root_integer, added and the result converted back to Universal_-
Integer.
root_integer is the anonymous greatest integer type representable by the hardware. It has
the range System.Min_Integer .. System.Max_Integer. All integer types are rooted
at root_integer, i.e. derived from it. Universal_Integer can be viewed as root_-
integer'Class.
During run-time, computations of course are performed with range checks and overflow
checks on the appropriate subtype. Intermediate results may however exceed the range
limits. Thus with I, J, K of the subtype T above, the following code will return the correct
result:
I := 10;
J := 8;
K := (I + J) - 12;
--I := I + J; -- range check would fail, leading to Constraint_Error
66
Real literals are of type Universal_Real, and similar rules as the ones above apply accord-
ingly.
Types can be made from other types. Array types, for example, are made from two types,
one for the arrays' index and one for the arrays' components. An array, then, expresses an as-
sociation, namely that between one value of the index type and a value of the component type.
The type Color is the index type and the type Intensity is the component type of the
array type Colored_Point. See array42 .
5.11.1 Wikibook
• Ada Programming43
42 Chapter 11 on page 83
43 http://en.wikibooks.org/wiki/Ada%20Programming
67
Type System
68
6 Integer types
A range is a signed integer value which ranges from a First to a last Last. It is defined as
When a value is assigned to an object with such a range constraint, the value is checked for
validity and Constraint_Error exception1 is raised when the value is not within First to
Last.
When declaring a range type, the corresponding mathematical operators are implicitly
declared by the language at the same place.
The compiler is free to choose a suitable underlaying hardware type for this user defined
type.
The following Demo defines a new range from -5 to 10 and then prints the whole range out.
File: range_1.adb
with Ada ;
procedure Range_1 is
type Range_Type is range -5 .. 10;
begin
for A in Range_Type loop
I_IO.Put (
Item => A,
Width => 3,
Base => 10);
69
Integer types
end if;
end loop;
end Range_1;
6.2.1 Wikibook
• Ada Programming2
• Ada Programming/Types3
• Ada Programming/Keywords/range4
2 http://en.wikibooks.org/wiki/Ada%20Programming
3 http://en.wikibooks.org/wiki/Ada%20Programming%2FTypes
4 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Frange
5 http://es.wikibooks.org/wiki/Programaci%F3n%20en%20Ada%2FTipos%2FEnteros
70
7 Unsigned integer types
7.1 Description
Description
Unsigned integers in Ada have a value range from 0 to some positive number (not necessarily
1 subtracted from some power of 2). They are defined using the mod keyword because they
implement a wrap-around arithmetic.
mod Modulus
for which also shift and rotate operations are defined. The values of n depend on compiler
and target architecture.
You can use range to sub-range a modular type:
But beware: the Modulus of Half_Byte is still 256! Arithmetic with such a type is interesting
to say the least.
71
Unsigned integer types
See also
7.2.1 Wikibook
• Ada Programming1
• Ada Programming/Types2
• Ada Programming/Keywords/mod3
1 http://en.wikibooks.org/wiki/Ada%20Programming
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FTypes
3 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Fmod
72
8 Enumerations
Like for numeric types, where e.g. 1 is an integer literal, Red, Green and Blue are called the
literals of this type. There are no other values assignable to objects of this type.
Apart from equality ("="), the only operators on enumeration types are the ordering
operators1 : "<", "<=", "=", "/=", ">=", ">", where the order relation is given implicitly by
the sequence of literals: Each literal has a position, starting with 0 for the first, incremented
by one for each successor. This position can be queried via the 'Pos attribute2 ; the inverse
is 'Val, which returns the corresponding literal. In our example:
Primary_Color'Pos (Red) = 0
Primary_Color'Val (0) = Red
There are two other important attributes: Image and Value (don't confuse Val with Value).
Image returns the string representation of the value (in capital letters), Value is the inverse:
These attributes are important for simple IO3 (there are more elaborate IO facilities in Ada
for enumeration types). Note that, since Ada is case-insensitive, the string given to 'Value
can be in any case.
73
Enumerations
Enumeration literals
Literals are overloadable, i.e. you can have another type with the same literals.
Overload resolution within the context of use of a literal normally resolves which Red is
meant. Only if you have an unresolvable overloading conflict, you can qualify with special
syntax which Red is meant:
Primary_Color'(Red)
Like many other declarative items, enumeration literals can be renamed. In fact, such a
literal is a actually function4 , so it has to be renamed as such:
This literal 'A' has nothing in common with the literal 'A' of the predefined type Character
(or Wide_Character).
Every type that has at least one character literal is a character type. For every character
type, string literals and the concatenation operator "&"5 are also implicitly defined.
74
Ada's Character type is defined that way. See Ada Programming/Libraries/Standard6 .
There is special semantics implied with this declaration in that objects and expressions
of this type can be used as conditions. Note that the literals False and True are not Ada
keywords.
Thus it is not sufficient to declare a type with these literals and then hope objects of this
type can be used like so:
If you need your own Booleans (perhaps with special size requirements), you have to derive
from the predefined Boolean:
if Condition then -- OK
75
Enumerations
See also
8.4.1 Wikibook
• Ada Programming7
• Ada Programming/Types8
• Ada Programming/Libraries/Standard9
7 http://en.wikibooks.org/wiki/Ada%20Programming
8 http://en.wikibooks.org/wiki/Ada%20Programming%2FTypes
9 Chapter 41 on page 333
10 http://es.wikibooks.org/wiki/Programaci%F3n%20en%20Ada%2FTipos%2FEnumeraciones
76
9 Floating point types
9.1 Description
Description
w:Floating point1
To define a floating point type, you only have to say how many digits2 are needed, i.e. you
define the relative precision:
digits Num_Digits
If you like, you can declare the minimum range needed as well:
This facility is a great benefit of Ada over (most) other programming languages. In other
languages, you just choose between "float" and "long float", and what most people do is:
• choose float if they don't care about accuracy
• otherwise, choose long float, because it is the best you can get
In either case, you don't know what accuracy you get.
In Ada, you specify the accuracy you need, and the compiler will choose an appropriate
floating point type with at least the accuracy you asked for. This way, your requirement is
guaranteed. Moreover, if the computer has more than two floating point types available, the
compiler can make use of all of them.
9.2.1 Wikibook
• Ada Programming4
1 http://en.wikipedia.org/wiki/Floating%20point
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Fdigits
4 http://en.wikibooks.org/wiki/Ada%20Programming
77
Floating point types
• Ada Programming/Types5
• Ada Programming/Types/range6
• Ada Programming/Types/delta7
• Ada Programming/Types/mod8
• Ada Programming/Keywords/digits9
5 http://en.wikibooks.org/wiki/Ada%20Programming%2FTypes
6 Chapter 6 on page 69
7 Chapter 10 on page 79
8 Chapter 7 on page 71
9 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Fdigits
10 http://es.wikibooks.org/wiki/Programaci%F3n%20en%20Ada%2FTipos%2FComa%20flotante
78
10 Fixed point types
10.1 Description
Description
w:Fixed-point arithmetic1 A fixed point type defines a set of values that are evenly spaced
with a given absolute precision. In contrast, floating point values are all spaced according to
a relative precision.
The absolute precision is given as the delta of the type. There are two kinds of fixed point
types, ordinary and decimal.
For Ordinary Fixed Point types, the delta gives a hint to the compiler how to choose the
small value if it is not specified: It can be any integer power of two not greater than delta.
You may specify the small via an attribute clause to be any value not greater than delta. (If
the compiler cannot conform to this small value, it has to reject the declaration.)
For Decimal Fixed Point types, the small is defined to be the delta, which in turn must
be an integer power of ten. (Thus you cannot specify the small by an attribute clause.)
For example, if you define a decimal fixed point type with a delta of 0.1, you will be able to
accurately store the values 0.1, 1.0, 2.2, 5.7, etc. You will not be able to accurately store
the value 0.01. Instead, the value will be rounded down to 0.0.
If the compiler accepts your fixed point type definition, it guarantees that values represented
by that type will have at least the degree of accuracy specified (or better). If the compiler
cannot support the type definition (e.g. due to limited hardware) then a compile-time error
will result.
For an ordinary fixed point, you just define the delta and a range:
The delta can be any real value — for example you may define a circle with one arcsecond
resolution with:
1 http://en.wikipedia.org/wiki/Fixed-point%20arithmetic
79
Fixed point types
[There is one rather strange rule about fixed point types: Because of the way they are
internally represented, the range might only go up to 'Last - Delta. This is a bit like a
circle — the 0° and 360° mark is also the same.]
It should be noted that in the example above the smallest possible value used is not 6012 = 3600
1
.
The compiler will choose a smaller value which, by default, is an integer power of 2 not
1
greater than the delta. In our example this could be 2−12 = 4096 . In most cases this should
render better performance but sacrifices precision for it.
If this is not what you wish and precision is indeed more important, you can choose your
own small value via the attribute clause 'Small.
You define a decimal fixed point by defining the delta and the number of digits needed:
Delta must be a positive or negative integer power of 10 — otherwise the declaration is illegal.
There is an alternative way of declaring a "decimal" fixed point: You declare an ordinary
fixed point and use an integer power of 10 as 'Small. The following two declarations are
80
equivalent with respect to the internal representation:
You might wonder what the difference then is between these two declarations. The answer
is:
None with respect to precision, addition, subtraction, multiplication with integer values.
The following is an incomplete list of differences between ordinary and decimal fixed point
types.
• Decimal fixed point types are intended to reflect typical COBOL declarations with a
given number of digits.
• Truncation is required for decimal, not for ordinary, fixed point in multiplication and di-
vision (RM 4.5.5 (21) ˆ{http://www.adaic.org/resources/add_content/standards/
95lrm/ARM_HTML/RM-4-5-5.html} ) and type conversions. Operations on decimal fixed
point are fully specified, which is not true for ordinary fixed point.
• The following attributes are only defined for decimal fixed point: T'Digits (RM
3.5.10 (10) ˆ{http://www.adaic.org/resources/add_content/standards/95lrm/
ARM_HTML/RM-3-5-10.html} ) corresponds to the number of decimal digits that
are representable; T'Scale (RM 3.5.10 (11) ˆ{http://www.adaic.org/resources/
add_content/standards/95lrm/ARM_HTML/RM-3-5-10.html} , taken from COBOL)
indicates the position of the point relative to the rightmost significant dig-
its; T'Round (RM 3.5.10 (12) ˆ{http://www.adaic.org/resources/add_content/
standards/95lrm/ARM_HTML/RM-3-5-10.html} ) can be used to specify rounding on
conversion.
• Package Decimal (RM F.2 ˆ{http://www.adaic.org/resources/add_content/
standards/95lrm/ARM_HTML/RM-F-2.html} ), which of course applies only to decimal
fixed point, defines the decimal Divide generic procedure. If annex F is supported (GNAT
does), at least 18 digits must be supported (there is no such rule for fixed point).
• Decimal_IO (RM A.10.1 (73) ˆ{http://www.adaic.org/resources/add_content/
standards/95lrm/ARM_HTML/RM-A-10-1.html} ) has semantics different from Fixed_-
IO (RM A.10.1 (68) ˆ{http://www.adaic.org/resources/add_content/standards/
95lrm/ARM_HTML/RM-A-10-1.html} ).
• Static expressions must be a multiple of the Small for decimal fixed point.
Conclusion: For normal numeric use, an ordinary fixed point (probably with 'Small
defined) should be defined. Only if you are interested in COBOL like use, i.e. well defined
deterministic decimal semantics (especially for financial computations, but that might apply
to cases other than money) should you take decimal fixed point.
81
Fixed point types
10.5.1 Wikibook
• Ada Programming2
• Ada Programming/Types3
• Ada Programming/Types/range4
• Ada Programming/Types/digits5
• Ada Programming/Types/mod6
• Ada Programming/Keywords/delta7
• Ada Programming/Attributes/'Small8
2 http://en.wikibooks.org/wiki/Ada%20Programming
3 http://en.wikibooks.org/wiki/Ada%20Programming%2FTypes
4 Chapter 6 on page 69
5 Chapter 9 on page 77
6 Chapter 7 on page 71
7 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Fdelta
8 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Small
9 http://es.wikibooks.org/wiki/Programaci%F3n%20en%20Ada%2FTipos%2FComa%20fija
82
11 Arrays
An array1 is a collection of elements which can be accessed by one or more index values. In
Ada any definite type is allowed as element and any discrete type, i.e. Range2 , Modular3 or
Enumeration4 , can be used as an index.
Ada's arrays are quite powerful and so there are quite a few syntax variations, which are
presented below.
where Index_Range is a range of values within a discrete index type, and Element_Type is
a definite subtype. The array consists of one element of "Element_Type" for each possible
value in the given range. If you for example want to count how often a specific letter
appears inside a text, you could use:
As a general advice, do not use Integer as the index range, since most of the time negative
indices do not make sense. It is also a good style when using numeric indices, to define them
starting in 1 instead of 0, since it is more intuitive for humans and avoids off-by-one error5 s.
1 http://en.wikipedia.org/wiki/array
2 Chapter 6 on page 69
3 Chapter 7 on page 71
4 Chapter 8 on page 73
5 http://en.wikipedia.org/wiki/off-by-one%20error
83
Arrays
Often you don't need an array of all possible values of the index type. In this case you can
subtype your index type to the actually needed range.
Since this may involve a lot of typing and you may also run out of useful names for new
subtypes6 , the array declaration allows for a shortcut:
Since First and Last are expressions of Index_Type, a simpler form of the above is:
Note that if First and Last are numeric literals, this implies the index type Integer.
If in the example above the character counter should only count upper case characters and
discard all other characters, you can use the following array type:
Sometimes the range actually needed is not known until runtime or you need ob-
jects of different lengths. In some languages you would resort to pointers to element
types. Not with Ada. Here we have the box '<>', which allows us to declare indefinite arrays:
When you declare objects of such a type, the bounds must of course be given and the object
is constrained to them.
The predefined type String7 is such a type. It is defined as
6 http://en.wikibooks.org/wiki/ada%20Programming%2FSubtypes
7 Chapter 15 on page 119
84
You define objects of such an unconstrained type in several ways (the extrapolation to other
arrays than String should be obvious):
(These declarations additionally define anonymous subtypes of String.) In the first example,
the range of indices is explicitly given. In the second example, the range is implicitly defined
from the initial expression, which here could be via a function reading data from some file.
Both objects are constrained to their ranges, i.e. they cannot grow nor shrink.
If you come from C8 /C++9 , you are probably used to the fact that every element of an
array has an address. The C10 /C++11 standards actually demand that.
In Ada, this is not true. Consider the following array:
Since we have packed the array, the compiler will use as little storage as possible. And in
most cases this will mean that 8 boolean values will fit into one byte.
So Ada knows about arrays where more than one element shares one address. So what
if you need to address each single element. Just not using pragma12 Pack13 is not
enough. If the CPU14 has very fast bit access, the compiler might pack the array without
being told. You need to tell the compiler that you need to address each element via an access.
Arrays can have more than one index. Consider the following 2-dimensional array:
8 http://en.wikibooks.org/wiki/Programming%3AC
9 http://en.wikibooks.org/wiki/Programming%3AC_plus_plus
10 http://en.wikibooks.org/wiki/Programming%3AC
11 http://en.wikibooks.org/wiki/Programming%3AC_plus_plus
12 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Fpragma
13 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPack
14 http://en.wikipedia.org/wiki/CPU
85
Arrays
type Character_Display is
array ( Positive range <> , Positive range <> ) of Character;
The index values of the second dimension, those indexing the characters in each row, are
in 1 .. 5 here. By choosing a different second range, we could change these to be in 11 .. 15:
By adding more dimensions to an array type, we could have squares, cubes (or « bricks »),
etc., of homogenous data items.
Finally, an array of characters is a string (see Ada Programming/Strings15 ). Therefore,
Magic_Square may simply be declared like this:
86
Using arrays
11.2.1 Assignment
When accessing elements, the index is specified in parentheses. It is also possible to access
slices in this way:
Note that the index range slides in this example: After the assignment, Vector_A (1) =
Vector_B (3) and similarly for the other indices.
Also note that the ranges overlap, nevertheless Vector_A (3) /= Vector_B (3); a compiler
delivering such a result would be severely broken.
11.2.2 Concatenate
In both cases, if the resulting array does not fit in the destination array, Constraint_Error
is raised.
If you try to access an existing element by indexing outside the array bounds, Constraint_-
Error is raised (unless checks are suppressed).
There are four Attributes which are important for arrays: 'First, 'Last, 'Length and 'Range.
Lets look at them with an example. Say we have the following three strings:
87
Arrays
2. The assumption (which follows from the first one) that X'Length = X'Last is wrong.
3. And last the assumption that X'Last >= X'First; this is not true for empty strings.
The attribute 'Range is a little special as it does not return a discrete value but an abstract
description of the array. One might wonder what it is good for. The most common use is in
the for loop on arrays16 but 'Range can also be used in declaring a name for the index subtype:
As you have seen in the section above, Ada allows for empty arrays. And — of course —
you can have empty arrays of all sorts, not just String:
Note: If you give an initial expression to an empty array (which is a must for a constant),
the expression in the aggregate will of course not be evaluated since there are no elements
actually stored.
11.3.1 Wikibook
• Ada Programming17
• Ada Programming/Types18
• Data Structures19
• Data Structures/Arrays20
16 Chapter 4 on page 37
17 http://en.wikibooks.org/wiki/Ada%20Programming
18 http://en.wikibooks.org/wiki/Ada%20Programming%2FTypes
19 http://en.wikibooks.org/wiki/Data%20Structures
20 http://en.wikibooks.org/wiki/Data%20Structures%2FArrays
88
11.3.2 Ada 95 Reference Manual
21 http://es.wikibooks.org/wiki/Programaci%F3n%20en%20Ada%2FTipos%2FArrays
89
12 Records
A record is a composite type1 that groups one or more fields. A field can be of any type,
even a record.
type Basic_Record is
record
A : Integer;
end record;
The null record is when a type without data is needed. There are two ways to declare a null
record:
type Null_Record is
record
null;
end record;
For the compiler they are the same. However, programmers often use the first variant if the
type is not finished yet to show that they are planning to expand the type later, or they
usually use the second if the (tagged) record is a base class in object oriented programming.
Values of a record type can be specified using a record aggregate, giving a list of named
components thus
1 http://en.wikibooks.org/wiki/ada%20Programming%2FTypes%23List%20of%20types
91
Records
a value may be specified using positional notation, that is, specifying a value for each record
component in declaration order
BMW : Car :=
( Identity => 2007_752_83992434,
Number_Wheels => 5,
Horse_Power_kW => 190. 0,
Consumption => 10. 1,
Paint => Blue) ;
In order to access a component of a record instance, use the dot delimiter (. ), as in BMW.
Number_Wheels.
2 http://www.adacore.com/2007/05/14/gem-1/
92
12.4 Discriminated record
Discriminated record
The variant record is a special type of discriminated record where the presence of some
components depend on the value of the discriminant.
case Option is
when Red =>
--components for red
when Yellow =>
--components for yellow
when Green =>
--components for green
end case;
end record;
You can declare variant record types such that its discriminant, and thus its variant structure,
can be changed during the lifetime of the variable. Such a record is said to be mutable.
When "mutating" a record, you must assign all components of the variant structure which
you are mutating at once, replacing the record with a complete variant structure. Although
a variant record declaration may allow objects of its type to be mutable, there are certain
restrictions on whether the objects will be mutable. Reasons restricting an object from being
mutable include:
• the object is declared with a discriminant (see Immutable_Traffic_Light below)
• the object is aliased (either by use of aliased in the object declaration, or by allocation
on the heap using new)
type Traffic_Light is (Red, Yellow, Green);
93
Records
case Option is
when Red =>
--components for red
Flashing : Boolean := True;
when Yellow =>
--components for yellow
Timeout : Duration := 0.0;
when Green =>
--components for green
Whatever : Positive := 1;
end case;
end record;
...
Mutable_Traffic_Light : Mutable_Variant_Record;
--not declaring a discriminant makes this record mutable
Conversely, you can declare record types so that the discriminant along with the structure
of the variant record may not be changed. To make a record type declaration immutable,
the discriminant must not have a default value.
type Immutable_Variant_Record (Option : Traffic_Light) is --no default value makes the record
type immutable
record
--common components
Location : Natural := 0;
case Option is
when Red =>
--components for red
Flashing : Boolean := True;
when Yellow =>
--components for yellow
Timeout : Duration;
when Green =>
--components for green
Whatever : Positive := 1;
end case;
end record;
94
...
Default_Traffic_Light : Immutable_Variant_Record;
--ILLEGAL!
Immutable_Traffic_Light : Immutable_Variant_Record (Option =>
Yellow); --this record is immutable, since the type declaration is immutable
12.6 Union
Union
case Option is
when Red =>
--components for red
when Yellow =>
--components for yellow
when Green =>
--components for green
end case;
end record;
pragma (Union);
pragma (C, Union); --optional
The difference to a variant record is such that Option is not actually stored inside the record
and never checked for correctness - it's just a dummy.
This kind of record is usually used for interfacing with C but can be used for other purposes
as well (then without pragma (C, Union);).
The tagged record is one part of what in other languages is called a class. It is the basic
foundation of object orientated programming in Ada3 . The other two parts a class in Ada
needs is a package4 and primitive operations5 .
95
Records
An abstract type has at least an abstract primitive operation, i.e. one of its operations is
not defined and then its derivative types has to provide an implementation.
If you come from C6 /C++7 , you are probably used to the fact that every element of a
record - which is not part of a bitset - has an address. In Ada, this is not true because
records, just like arrays, can be packed. And just like arrays you can use aliased to ensure
that an element can be accessed via an access type.
type Basic_Record is
record
A : aliased Integer;
end record ;
6 http://en.wikibooks.org/wiki/C%20Programming
7 http://en.wikibooks.org/wiki/C%2B%2B%20Programming
96
12.10 Limited Records
Limited Records
In addition to being variant, tagged, and abstract, records may also be limited (no assignment,
and no predefined equality operation for Limited Types8 ). In object oriented programming,
when tagged objects are handled by references instead of copying them, this blends well
with making objects limited.
12.11.1 Wikibook
• Ada Programming9
• Ada Programming/Types10
• Ada Programming/Keywords/record11
• Ada Programming/Keywords/null12
• Ada Programming/Keywords/abstract13
• Ada Programming/Keywords/case14
• Ada Programming/Keywords/when15
• Ada Programming/Pragmas/Unchecked_Union16
Ada 95
Ada 2005
97
Records
Ada Issues
98
13 Access types
Access types in Ada are what other languages call pointers. They point to objects located
at certain addresses. So normally one can think of access types as simple addresses (there
are exceptions from this simplified view). Ada instead of saying points to talks of granting
access to or designating an object.
Objects of access types are implicitly initialized with null, i.e. they point to nothing when
not explicitly initialized.
Access types should be used rarely in Ada. In a lot of circumstances where pointers are
used in other languages, there are other ways without pointers. If you need dynamic
data structures, first check whether you can use the Ada Container library. Especially
for indefinite record or array components, the Ada 2012 package Indefinite_Holders (RM
A.18.18) can be used instead of pointers.
There are four kinds of access types in Ada: Pool access types - General access types -
Anonymous access types - Access to subprogram types.
A pool access type handles accesses to objects which were created on some specific heap (or
storage pool as it is called in Ada). A pointer of these types cannot point to a stack or
library level (static) object or an object in a different storage pool. Therefore, conversion
between pool access types is illegal. (Unchecked_Conversion may be used, but note that
deallocation via an access object with a storage pool different from the one it was allocated
with is erroneous.)
99
Access types
A size clause may be used to limit the corresponding (implementation defined anonymous)
storage pool. A size clause of 0 disables calls of an allocator.
The storage pool is implementation defined if not specified. Ada supports user defined
storage pools, so you can define the storage pool with
You access the object in the storage pool by appending .all. Mother.all is the complete
record; components are denoted as usual with the dot notation: Mother.all.First_Name.
When accessing components, implicit dereferencing (i.e. omitting all) can serve as a
convenient shorthand:
Be careful to discriminate between deep and shallow copies when copying with access objects:
100
13.2.1 Deleting objects from a storage pool
Although the Ada standard mentions a garbage collector, which would automatically remove
all unneeded objects that have been created on the heap (when no storage pool has been
defined), only Ada compilers targeting a virtual machine like Java or .NET actually have
garbage collectors. There is also a pragma Controlled, which, when applied to such an
access type, prevents automatic garbage collection of objects created with it. Note that
pragma Controlled will be dropped from Ada 2012, see RM 2012 13.11.3.
Therefore in order to delete an object from the heap, you need the generic unit Ada . Apply
utmost care to not create dangling pointers when deallocating objects as is shown in the
example below. (And note that deallocating objects with a different access type than the one
with which they were created is erroneous when the corresponding storage pools are different.)
with Ada ;
procedure Deallocation_Sample is
begin
end Deallocation_Sample;
It is exactly because of this problem with dangling pointers that the deallocation operation
is called unchecked. It is the chore of the programmer to take care that this does not
happen.
Since Ada allows for user defined storage pools, you could also try a garbage collector
library1 .
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FMultiPurpose%2FAdaCL%
1
23Garbage_Collector
101
Access types
You can find some implementations of reference counting pointers, called Safe or Smart
Pointers, on the net. Using such a type prevents caring about deallocation, since this will
automatically be done when there are no more pointers to an object. But be careful - most of
those implementations do not prevent deliberate deallocation, thus undermining the alledged
safety attained with their use.
A nice tutorial how to construct such a type can be found in a series of Gems on the AdaCore
web site.
Gem #97: Reference Counting in Ada – Part 12 This little gem constructs a simple reference
counted pointer that does not prevent deallocation, i.e. is inherently unsafe.
Gem #107: Preventing Deallocation for Reference-counted Types3 This further gem describes
how to arrive at a pointer type whose safety cannot be compromised (tasking issues aside).
The cost of this improved safety is awkward syntax.
Gem #123: Implicit Dereferencing in Ada 20124 This gem shows how to simplify the syntax
with the new Ada 2012 generation. (Admittedly, this gem is a bit unrelated to reference
counting since the new language feature can be applied to any kind of container.)
General access types grant access to objects created on any storage pool, on the stack or
at library level (static). They come in two versions, granting either read-write access or
read-only access. Conversions between general access types are allowed, but subject to
certain access level checks.
Dereferencing is like for pool access types. Objects (other than pool objects) to be referenced
have to be declared aliased, and references to them are created with the attribute 'Access.
Access level restrictions prevent accesses to objects from outliving the accessed object,
which would make the program erroneous. The attribute 'Unchecked_Access omits the
corresponding checks.
When the keyword all is used in their definition, they grant read-write access.
2 http://www.adacore.com/2011/01/17/gem-97-reference-counting-in-ada-part-1/
3 http://www.adacore.com/2011/06/06/gem-107-preventing-deallocation-for-reference-counted-types/
4 http://www.adacore.com/adaanswers/gems/gem-123-implicit-dereferencing-in-ada-2012/
102
13.3.2 Access to Constant
General access types granting read-only access to the referenced object use the keyword
constant in their definition. The referenced object may be a constant or a variable.
Also Anonymous access types come in two versions like general access types, granting either
read-write access or read-only access depending on whether the keyword constant appears.
An anonymous access can be used as a parameter to a subprogram or as a discriminant.
Here are some examples:
Before using an anonymous access, you should consider a named access type or, even better,
consider if the "out" or "in out" modifier is not more appropriate.
This language feature is only available in Ada 2005
In Ada 2005, anonymous accesses are allowed in more circumstances:
103
Access types
X: access Integer;
Ada 2012 will simplify accesses to objects via pointers with new syntax.
Imagine you have a container holding some kind of elements.
Now how do you access elements stored in the container. Of course you can retrieve them by
This will however copy the element, which is unfortunate if the element is big. You get
direct access with
Now pointers are dangerous since you might easily create dangling pointers like so:
Use of an accessor object instead of an access type can prevent inadvertant deallocation
(this is still Ada 2005):
type Accessor (Data: not null access Element) is limited private; -- read/write access
function Get (From: Container) return Accessor;
(For the null exclusion not null in the declaration of the discriminant, see below). Access
via such an accessor is safe: The discriminant can only be used for dereferencing, it cannot
be copied to an object of type Element_Ptr because its accessibility level is deeper. In the
104
form above, the accessor provides read and write access. If the keyword constant is added,
only read access is possible.
type Accessor (Data: not null access constant Element) is limited private; -- only read access
Here the new Ada 2012 feature of aspects comes along handy; for the case at hand, the
aspect Implicit_Dereference is the one we need:
Now rather than writing the long and ugly function call of above, we can just omit the
discriminant and its dereference like so:
Note that the call Get (Cont) is overloaded — it can denote the accessor object or the
element, the compiler will select the correct interpretation depending on context.
The language also allows to declare the first subtype directly with a null exclusion:
However, in nearly all cases this is not a good idea because it renders objects of this type nearly
unusable (for example, you are unable to free the allocated memory). Not null accesses
are intended for access subtypes, object declarations, and subprogram parameters.http:
//groups.google.com/group/comp.lang.ada/msg/13a41ced7af75192
105
Access types
An access to subprogram allows to call a subprogram5 without knowing its name nor its
declaration location. One of the uses of this kind of access is the well known callbacks.
function F return access function return access function return access Some_Type;
This is a function that returns the access to a function that in turn returns an access to a
function returning an access to some type.
A few "Frequently Asked Question" and "Frequently Encountered Problems" (mostly from
C6 users) regarding Ada's access types.
106
13.8.1 Access vs. access all
An access all can do anything a simple access can do. So one might ask: "Why use simple
access at all?" - And indeed some programmers never use simple access.
Unchecked_Deallocation is always dangerous if misused. It is just as easy to deallocate
a pool-specific object twice, and just as dangerous as deallocating a stack object. The
advantage of "access all" is that you may not need to use Unchecked_Deallocation at all.
Moral: if you have (or may have) a valid reason to store an 'Access or 'Unchecked_Access
into an access object, then use "access all" and don't worry about it. If not, the mantra of
"least privilege" suggests that the "all" should be left out (don't enable capabilities that you
are not going to use).
The following (perhaps disastrous) example will try to deallocate a stack object:
declare
A : aliased Day_Of_Month;
Ptr: Day_Of_Month_Access := A'Access;
begin
Free(Ptr);
end;
With a simple access you know at least that you won't try to deallocate a stack object.
An access can be something different from a mere memory address, it may be something
more. For example, an "access to String" often needs some way of storing the string size
as well. If you need a simple address and are not concerned about strong typing, use the
System.Address type.
107
Access types
pragma should be used on any type you want to use in C. The compiler will warn you if
the type cannot be made C compatible.
You may also consider the following - shorter - alternative when declaring Day_Of_Month:
Before you use access types in C, you should consider using the normal "in", "out" and "in
out" modifiers. pragma and pragma know how parameters are usually passed in C and
will use a pointer to pass a parameter automatically where C would have used them as
well. Of course the RM contains precise rules on when to use a pointer for "in", "out", and
"in out" - see "B.3 Interfacing with C ˆ{http://www.adaic.org/resources/add_content/
standards/05rm/html/RM-B-3.html} ".
While actually a problem for "interfacing with C", here are some possible solutions:
procedure Test is
Pointer: Pvoid;
begin
Pointer := Input_Parameter'Address;
Return_Value := C_fun (Pointer);
end Test;
108
With GNAT you can get 32/64 bit portability by using:
Closer to the true nature of void - pointing to an element of zero size is a pointer to a null
record. This also has the advantage of having a representation for void and void*:
The difference between an access type and an address will be detailed in the following. The
term pointer is used because this is usual terminology.
There is a predefined unit System.Address_to_Access_Conversion converting back and
forth between access values and addresses. Use these conversions with care, as is explained
below.
Objects of subtypes like these have a static size, so a simple address suffices to access them.
In the case of arrays, this is generally the address of the first element.
For pointers of this kind, use of System.Address_to_Access_Conversion is safe.
109
Access types
Objects of subtype Unc need a constraint, i.e. a start and a stop index, thus pointers to
them need also to include those. So a simple address like the one of the first component is
not sufficient. Note that A'Address is the same as A(A'First)'Address for any array object.
For pointers of this kind, System.Address_to_Access_Conversion will probably not work
satisfactorily.
13.9.3 Example
Here, CO is a nominally constrained object, a pointer to it need not store the constraint, i.e.
a thin pointer suffices. In contrast, UO is an object of a nominally unconstrained subtype,
its actual subtype is constrained by the initial value.
13.10.1 Wikibook
• Ada Programming7
• Ada Programming/Types8
7 http://en.wikibooks.org/wiki/Ada%20Programming
8 http://en.wikibooks.org/wiki/Ada%20Programming%2FTypes
110
13.10.2 Ada Reference Manual
Ada 95
Ada 2005
111
14 Limited types
When a type is declared limited this means that objects of the type cannot be assigned
values of the same type. An Object b of limited type LT cannot be copied into an object a
of same type LT.
Additionally, there is no predefined equality operation for objects of a limited type.
The desired effects of declaring a type limited include prevention of shallow copying. Also,
the (unique) identity of an object is retained: once declared, a name of a variable of type LT
will continue to refer to the same object.
The following example will use a rather simplifying type Boat.
function Choose
( Load : Sailors_Units;
Speed : Sailors_Units)
return Boat;
When we declare a variable to be of type Boat, its name will denote one boat from then on.
Boats will not be copied into one another.
The full view of a boat might be implemented as a record such as
The Choose function returns a Boat object depending on the parameters Load and Speed.
If we now declare a variable of type Boat we will be better off Choosing an initial Boat (or
else we might be dropping into uninitialized waters!). But when we do so, the initialization
looks suspiciously like assignment which is not available with limited types:
113
Limited types
begin
Set_Sail ( Henrietta) ;
end Travel;
Fortunately, current Ada distinguishes initialization from copying. Objects of a limited type
may be initialized by an initialization expression on the right of the delimiter := .
(Just to prevent confusion: The Ada Reference Manual discriminates between assignment
and assignment statement, where assignment is part of the assignment statement. An
initialisation is of course an assignment which, for limited types, is done in place. An
assignment statement involves copying, which is forbidden for limited types.)
Related to this feature are aggregates of limited types1 and “constructor functions”
for limited types. Internally, the implementation of the Choose function will return
a limited record. However, since the return type Boat is limited, there must be no
copying anywhere. Will this work? A first attempt might be to declare a result variable
local to Choose, manipulate result, and return it. The result object needs to be
“transported” into the calling environment. But result is a variable local to Choose.
When Choose returns, result will no longer be in scope. Therefore it looks like result
must be copied but this is not permitted for limited types. There are two solutions
provided by the language: extended return statements (see 6.5 Return Statements ˆ{http:
//www.adaic.org/resources/add_content/standards/05rm/html/RM-6-5.html} ) and
aggregates of limited types. The following body of Choose returns an aggregate of limited
type Boat, after finding the initial values for its components.
function Choose
( Load : Sailors_Units;
Speed : Sailors_Units)
return Boat
is
Capacity : constant Sailors_Units := Capacity_Needed ( Load) ;
begin
return Boat'
( Max_Freight => Capacity,
Max_Sail_Area => Sail_Needed ( Capacity) ,
Freight => Load,
Sail_Area => 0. 0) ;
end Choose;
The object that is returned is at the same time the object that is to have the returned value.
The function therefore initializes Henrietta in place.
In parallel to the predefined type Ada .Controlled, Ada provides the type Limited_-
Controlled in the same package. It is a limited version of the former.
1 http://www.adacore.com/2007/05/14/gem-1/
114
14.2 Initialising Limited Types
Initialising Limited Types
package Limited_Private_Samples is
private
end Limited_Private_Samples;
end Limited_Private_Samples;
115
Limited types
with Limited_Private_Samples;
use Limited_Private_Samples;
procedure Try is
begin
null;
end Try;
X, Y: Preinitialised;
In this declaration of two objects, the initial expression will be evaluated twice and can
deliver different values, because it is equivalent to the sequence2 :
X: Preinitialised;
Y: Preinitialised;
So X is initialised before Y.
2 ISO/IEC 8652:2007. 3.3.1 Object Declarations (7). Ada 2005 Reference Manual. Any declaration
[...] with more than one defining_identifier is equivalent to a series of declarations each containing
one defining_identifier from the list, [...] in the same order as the list. ˆ{http://www.adaic.org/
resources/add_content/standards/05rm/html/RM-3-3-1.html}
116
14.3.2 Ada 2005 Reference Manual
14.4 References
References
117
15 Strings
Ada supports three different types of strings. Each string type is designed to solve a different
problem.
In addition, every string type is implemented for each available Characters type (Character,
Wide_Character, Wide_Wide_Character) giving a complement of nine combinations.
Fixed-Length Strings are arrays1 of Character, and consequently of a fixed length. Since
a fixed length string is an indefinite subtype2 the length does not need to be known at
compile time — the length may well be calculated at run time. In the following example
the length is calculated from command-line argument 1:
However once the length has been calculated and the strings have been created the length
stays constant. Try the following program which shows a typical mistake:
File: show_commandline_1.adb
with Ada ;
with Ada ;
procedure Show_Commandline_1 is
begin
T_IO.Put ("Argument 1 = ");
T_IO.Put_Line (X);
X := CL.Argument (2);
1 Chapter 11 on page 83
2 http://en.wikibooks.org/wiki/ada%20Programming%2FSubtypes%23indefinite%20subtype
119
Strings
T_IO.Put_Line (X);
end Show_Commandline_1;
The program will only work when the 1st and 2nd parameter have the same length. This
is even true when the 2nd parameter is shorter. There is neither an automatic padding of
shorter strings nor an automatic truncation of longer strings.
Having said that, the package Ada contains a set of procedures and functions for Fixed-
Length String Handling which allows padding of shorter strings and truncation of longer
strings.
Try the following example to see how it works:
File: show_commandline_2.adb
with Ada ;
with Ada ;
with Ada ;
procedure Show_Commandline_2 is
begin
T_IO.Put ("Argument 1 = ");
T_IO.Put_Line (X);
SF.Move (
Source => CL.Argument (2),
Target => X,
Drop => S.Right,
Justify => S.Left,
Pad => S.Space);
Bounded-Length Strings can be used when the maximum length of a string is known and/or
restricted. This is often the case in database applications where only a limited number of
characters can be stored.
120
Like Fixed-Length Strings the maximum length does not need to be known at compile time
— it can also be calculated at runtime — as the example below shows:
File: show_commandline_3.adb
with Ada ;
with Ada ;
with Ada ;
procedure Show_Commandline_3 is
function Max_Length (
Value_1 : Integer;
Value_2 : Integer)
return
Integer
is
Retval : Integer;
begin
if Value_1 > Value_2 then
Retval := Value_1;
else
Retval := Value_2;
end if;
return Retval;
end Max_Length;
package SB
is new Ada.Strings.Bounded.Generic_Bounded_Length (
Max => Max_Length (
Value_1 => CL.Argument (1)'Length,
Value_2 => CL.Argument (2)'Length));
X : SB.Bounded_String
:= SB.To_Bounded_String (CL.Argument (1));
begin
T_IO.Put ("Argument 1 = ");
T_IO.Put_Line (SB.To_String (X));
You should know that Bounded-Length Strings have some distinct disadvantages. Most
noticeable is that each Bounded-Length String is a different type which makes converting
them rather cumbersome. Also a Bounded-Length String type always allocates memory for
the maximum permitted string length for the type. The memory allocation for a Bounded-
Length String is equal to the maximum number of string "characters" plus an implementation
dependent number containing the string length (each character can require allocation of
more than one byte per character, depending on the underlying character type of the string,
121
Strings
and the length number is 4 bytes long for the Windows GNAT Ada compiler v3.15p, for
example).
Last but not least there is the Unbounded-Length String. In fact: If you are not doing
embedded or database programming this will be the string type you are going to use most
often as it gives you the maximum amount of flexibility.
As the name suggest the Unbounded-Length String can hold strings of almost any length —
limited only to the value of Integer'Last or your available heap memory. This is because
Unbounded_String type is implemented using dynamic memory allocation behind the
scenes, providing lower efficiency but maximum flexibility.
File: show_commandline_4.adb
with Ada ;
with Ada ;
with Ada ;
procedure Show_Commandline_4 is
X : SU.Unbounded_String
:= SU.To_Unbounded_String (CL.Argument (1));
begin
T_IO.Put ("Argument 1 = ");
T_IO.Put_Line (SU.To_String (X));
As you can see the Unbounded-Length String example is also the shortest (discarding the
first example, which is buggy) — this makes using Unbounded-Length Strings very appealing.
122
See also
15.4.1 Wikibook
• Ada Programming3
3 http://en.wikibooks.org/wiki/Ada%20Programming
123
16 Subprograms
In Ada the subprograms are classified into two categories: procedures1 and functions2 . A
procedures call is a statement and does not return any value, whereas a function returns a
value and must therefore be a part of an expression.
Subprogram parameters may have three modes.
in
The actual parameter value goes into the call and is not changed there. The formal
parameter is a constant and allows only reading. This is the default when no mode is given.
The actual parameter is an expression.
in out
The actual parameter goes into the call and may be redefined. The formal parameter is a
variable and can be read and written.
out
The actual parameter's value before the call is irrelevant, it will get a value in the call. The
formal parameter can be read and written. (In Ada 83 out parameters were write-only.)
A parameter of any mode may also be explicitly aliased.
access
The formal parameter is an access (a pointer) to some variable. (This is not a parameter
mode from the reference manual point of view.)
Note that parameter modes do not specify the parameter passing method. Their purpose is
to document the data flow.
The parameter passing method depends on the type of the parameter. A rule of thumb is
that parameters fitting into a register are passed by copy, others are passed by reference.
For certain types, there are special rules, for others the parameter passing mode is left to
the compiler (which you can assume to do what is most sensible). Tagged types are always
passed by reference.
Explicitly aliased parameters and access parameters specify pass by reference.
Unlike in the C class of programming languages, Ada subprogram calls cannot have empty
parameters parentheses ( ) when there are no parameters.
125
Subprograms
16.1 Procedures
Procedures
the expressions 5 + P and 48 are evaluated (expressions are only allowed for in parameters),
and then assigned to the formal parameters A and B, which behave like constants. Then,
the value A + B is assigned to formal variable C, whose value will be assigned to the actual
parameter Q when the procedure finishes.
C, being an out parameter, is an uninitialized variable before the first assignment. (Therefore
in Ada 83, there existed the restriction that out parameters are write-only. If you wanted to
read the value written, you had to declare a local variable, do all calculations with it, and
finally assign it to C before return. This was awkward and error prone so the restriction
was removed in Ada 95.)
Within a procedure, the return statement can be used without arguments to exit the
procedure and return the control to the caller.
For example, to solve an equation of the kind ax2 + bx + c = 0:
with Ada ;
use Ada ;
procedure Quadratic_Equation
( A, B, C : Float; --By default it is "in".
R1, R2 : out Float;
Valid : out Boolean)
is
Z : Float;
begin
Z := B**2 - 4.0 * A * C;
if Z < 0.0 or A = 0.0 then
Valid := False; --Being out parameter, it should be modified at least once.
R1 := 0.0;
R2 := 0.0;
else
Valid := True;
R1 := (-B + Sqrt (Z)) / (2.0 * A);
R2 := (-B - Sqrt (Z)) / (2.0 * A);
end if;
end Quadratic_Equation;
126
The function SQRT calculates the square root of non-negative values. If the roots are real,
they are given back in R1 and R2, but if they are complex or the equation degenerates (A
= 0), the execution of the procedure finishes after assigning to the Valid variable the False
value, so that it is controlled after the call to the procedure. Notice that the out parameters
should be modified at least once, and that if a mode is not specified, it is implied in.
16.2 Functions
Functions
A function is a subprogram that can be invoked as part of an expression. Until Ada 2005,
functions can only take in (the default) or access parameters; the latter can be used as a
work-around for the restriction that functions may not have out parameters. Ada 2012 has
removed this restriction.
Here is an example of a function body:
Or in Ada2012:
function Minimum (A, B: Integer) return Integer is (if A <= B then A else B);
The formal parameters with mode in behave as local constants whose values are provided by
the corresponding actual parameters. The statement return is used to indicate the value
returned by the function call and to give back the control to the expression that called
the function. The expression of the return statement may be of arbitrary complexity and
must be of the same type declared in the specification. If an incompatible type is used, the
compiler gives an error. If the restrictions of a subtype are not fulfilled, e.g. a range, it
raises a Constraint_Error exception.
The body of the function can contain several return statements and the execution of any
of them will finish the function, returning control to the caller. If the flow of control within
the function branches in several ways, it is necessary to make sure that each one of them is
finished with a return statement. If at run time the end of a function is reached without
127
Subprograms
When evaluating the expression Factorial (4); the function will be called with parameter
4 and within the function it will try to evaluate the expression Factorial (3), calling itself
as a function, but in this case parameter N would be 3 (each call copies the parameters)
and so on until N = 1 is evaluated which will finalize the recursion and then the expression
will begin to be completed in the reverse order.
A formal parameter of a function can be of any type, including vectors or records. Never-
theless, it cannot be an anonymous type, that is, its type must be declared before, for example:
In this example, the function can be used on a vector of arbitrary dimension. Therefore,
there are no static bounds in the parameters passed to the functions. For example, it is
possible to be used in the following way:
In the same way, a function can also return a type whose bounds are not known a priori.
For example:
128
Result(I) := V (V'First + V'Last - I);
end loop;
return Result;
end Invert_Components;
The variable Result has the same bounds as V, so the returned vector will always have the
same dimension as the one passed as parameter.
A value returned by a function can be used without assigning it to a variable, it can be
referenced as an expression. For example, Invert_Components (V4) (1), where the first
element of the vector returned by the function would be obtained (in this case, the last
element of V4, i.e. 7.8).
In subprogram calls, named parameter notation (i.e. the name of the formal parameter
followed of the symbol => and then the actual parameter) allows the rearrangement of the
parameters in the call. For example:
Quadratic_Equation (Valid => OK, A => 1.0, B => 2.0, C => 3.0, R1 =>
P, R2 => Q);
F := Factorial (N => (3 + I));
The first call (from Ada.Numerics.Elementary_Functions) is not very clear. One might easily
confuse the parameters. The second call makes the meaning clear without any ambiguity.
Another use is for calls with numeric literals:
On the other hand, formal parameters may have default values. They can, therefore, be
omitted in the subprogram call. For example:
129
Subprograms
In the first statement, a "regular call" is used (with positional association); the second
also uses positional association but omits the second parameter to use the default; in the
third statement, all parameters are by default; the fourth statement uses named association
to omit the first parameter; finally, the fifth statement uses mixed association, here the
positional parameters have to precede the named ones.
Note that the default expression is evaluated once for each formal parameter that has no
actual parameter. Thus, if in the above example a function would be used as defaults for A
and B, the function would be evaluated once in case 2 and 4; twice in case 3, so A and B
could have different values; in the others cases, it would not be evaluated.
16.5 Renaming
Renaming
Subprograms may be renamed. The parameter and result profile for a renaming-as-
declaration must be mode conformant.
procedure Solve
(A, B, C: in Float;
R1, R2 : out Float;
Valid : out Boolean) renames Quadratic_Equation;
package Some_Package is
type Message_Type is tagged null record;
procedure Print (Message: in Message_Type);
end Some_Package;
with Some_Package;
procedure Main is
Message: Some_Package.Message_Type;
procedure Print renames Message.Print; --this has convention intrinsic, see RM 6.3.1(10.1/2)
Method_Ref: access procedure := Print'Access; --thus taking 'Access should be illegal; GNAT
GPL 2012 allows this
begin --All these calls are equivalent:
Some_Package.Print (Message); --traditional call without use clause
Message.Print; --Ada 2005 method.object call - note: no use clause necessary
Print; --Message.Print is a parameterless procedure and can be renamed
130
as such
Method_Ref.all; --GNAT GPL 2012 allows illegal call via an access to the renamed
procedure Print
--This has been corrected in the current version (as of Nov 22,
2012)
end Main;
But note that Message.Print'Access; is illegal, you have to use a renaming declaration
as above.
Since only mode conformance is required (and not full conformance as between specification
and body), parameter names and default values may be changed with renamings:
16.6.1 Wikibook
• Ada Programming3
• Ada Programming/Operators4
3 http://en.wikibooks.org/wiki/Ada%20Programming
4 Chapter 37 on page 301
131
Subprograms
5 http://es.wikibooks.org/wiki/Programaci%F3n%20en%20Ada%2FSubprogramas
132
17 Packages
Ada encourages the division of code into separate modules called packages. Each package
can contain any combination of items.
Some of the benefits of using packages are:
• package contents are placed in a separate namespace, preventing naming collisions,
• implementation details of the package can be hidden from the programmer (information
hiding),
• object orientation requires defining a type and its primitive subprograms within a package,
and
• packages can be separately compiled.
Some of the more common package usages are:
• a group of related subprograms along with their shared data, with the data not visible
outside the package,
• one or more data types along with subprograms for manipulating those data types, and
• a generic package that can be instantiated under varying conditions.
The following is a quote from the current Ada Reference Manual 7. Packages. RM
7(1) ˆ{http://www.adaic.org/resources/add_content/standards/05rm/html/RM-7-.
html}
Packages are program units that allow the specification of groups of logically related
entities. Typically, a package contains the declaration of a type (often a private type
or private extension) along with the declaration of primitive subprograms of the type,
which can be called from outside the package, while their inner workings remain hidden
from outside users.
It is very common for package declarations and package bodies to be coded into separate
files and separately compiled. Doing so places the package at the library level where it will
be accessible to all other code via the with statement—if a more restricted scope is desired,
simply declare the package (and package body, if needed) within the appropriate scope.
The package body can itself be divided into multiple files by specifying that one or more
subprogram implementations are separate.
133
Packages
One of the biggest advantages of Ada over most other programming languages is its well
defined system of modularization and separate compilation. Even though Ada allows
separate compilation, it maintains the strong type checking among the various compilations
by enforcing rules of compilation order and compatibility checking. Ada uses separate
compilation (like Modula-21 , Java2 and C#3 ), and not independent compilation (as C4 /C++5
does), in which the various parts are compiled with no knowledge of the other compilation
units with which they will be combined.
A note to C/C++ users: Yes, you can use the preprocessor to emulate separate compilation
— but it is only an emulation and the smallest mistake leads to very hard to find bugs. It
is telling that all C/C++ successor languages including D6 have turned away from the
independent compilation and the use of the preprocessor.
So it's good to know that Ada has had separate compilation ever since Ada-83 and is
probably the most sophisticated implementation around.
A package generally consists of two parts, the specification and the body. A package
specification can be further divided in two logical parts, the visible part and the private
part. Only the visible part of the specification is mandatory. The private part of the
specification is optional, and a package specification might not have a package body—the
package body only exists to complete any incomplete items in the specification. Subprogram
declarations are the most common incomplete items. There must not be a package body if
there is no incomplete declarations and there has to be a package body if there is incomplete
declarations in the specification.
To understand the value of the three-way division, consider the case of a package that has
already been released and is in use. A change to the visible part of the specification will
require that the programmers of all using software verify that the change does not affect the
using code. A change to the private part of the declaration will require that all using code be
recompiled but no review is normally needed. Some changes to the private part can change
the meaning of the client code however. An example is changing a private record type into
a private access type. This change can be done with changes in the private part, but change
the semantic meaning of assignment in the clients code. A change to the package body
will only require that the file containing the package body be recompiled, because nothing
outside of the package body can ever access anything within the package body (beyond the
declarations in the specification part).
A common usage of the three parts is to declare the existence of a record type and some
subprograms that operate on that type in the visible part, define the actual structure of the
1 http://en.wikipedia.org/wiki/Modula-2
2 http://en.wikipedia.org/wiki/Java_programming_language
3 http://en.wikipedia.org/wiki/C%20Sharp%20programming%20language
4 http://en.wikipedia.org/wiki/C%20programming%20language
5 http://en.wikipedia.org/wiki/C%2B%2B
6 http://en.wikipedia.org/wiki/D_programming_language
134
record type in the private part, and provide the code to implement the subprograms in the
package body.
The visible part of a package specification describes all the subprogram specifications,
variables, types, constants etc. that are visible to anyone who wishes to use the package.
package Public_Only_Package is
end Public_Only_Package;
private
end Package_With_Private;
The package body defines the implementation of the package. All the subprograms defined
in the specification have to be implemented in the body. New subprograms, types and
objects can be defined in the body that are not visible to the users of the package.
package Package_With_Body is
private
type Basic_Record is
record
A : Integer;
135
Packages
end record ;
pragma (Get_A);
pragma (Get_A);
pragma (Set_A);
end Package_With_Body;
end Package_With_Body;
pragma
Only available when using GNAT7 .
The packages above each define a type together with operations of the type. When the
type's composition is placed in the private part of a package, the package then exports what
is known to be an Abstract Data Type8 or ADT for short. Objects of the type are then
constructed by calling one of the subprograms associated with the respective type.
A different kind of package is the Abstract State Machine. A package will be modeling a
single item of the problem domain, such as the motor of a car. If a program controls one car,
there is typically just one motor, or the motor. The public part of the package specification
only declares the operations of the module (of the motor, say), but no type. All data of
the module are hidden in the body of the package where they act as state variables to be
queried, or manipulated by the subprograms of the package. The initialization part sets the
state variables to their initial values.
package Package_With_Body is
private
7 http://en.wikipedia.org/wiki/GNAT
8 http://en.wikipedia.org/wiki/Abstract_data_type
136
pragma Pure_Function ( Get_A) ;
end Package_With_Body;
The_A: Integer;
begin
The_A := 0;
end Package_With_Body;
To utilize a package it's needed to name it in a with clause, whereas to have direct visibility
of that package it's needed to name it in a use clause.
For C++ programmers, Ada's with clause is analogous to the C++ preprocessor's #include
and Ada's use is similar to the using namespace statement in C++. In particular, use
leads to the same namespace pollution problems as using namespace and thus should be
used sparingly. Renaming can shorten long compound names to a manageable length, while
the use type clause makes a type's operators visible. These features reduce the need for
plain use.
The standard with clause provides visibility for the public part of a unit to the following
defined unit. The imported package can be used in any part of the defined unit, including
the body when the clause is used in the specification.
9 http://en.wikipedia.org/wiki/Singleton_pattern
137
Packages
package Private_With is
private
--The visibility of package Ada.String.Unbounded starts here
type Basic_Record is
record
A : Unbounded.Unbounded_String;
end record;
pragma (Get_A);
pragma (Get_A);
pragma (Set_A);
end Private_With;
end Private_With;
package Employees is
138
type Employee is tagged private;
procedure Assign_Employee
(E : in out Employee;
D : access Departments.Department'Class);
package Departments is
procedure Choose_Manager
(Dept : in out Department;
Manager : access Employees.Employee'Class);
...
end Departments;
Suppose you have a package Universe that defines some numeric type T.
with Universe;
procedure P is
V: Universe. T := 10. 0;
begin
V := V * 42. 0; --illegal
end P;
This program fragment is illegal since the operators implicitly defined in Universe are not
directly visible.
You have four choices to make the program legal.
Use a use_package_clause. This makes all declarations in Universe directly visible
(provided they are not hidden because of other homographs).
with Universe;
use Universe;
procedure P is
V: Universe. T := 10. 0;
begin
V := V * 42. 0;
end P;
Use renaming. This is error prone since if you rename many operators, cut and paste errors
are probable.
139
Packages
with Universe;
procedure P is
function "*" ( Left, Right: Universe. T) return Universe. T renames Universe. "*";
function "/" ( Left, Right: Universe. T) return Universe. T renames Universe. "*";
--oops
V: Universe. T := 10. 0;
begin
V := V * 42. 0;
end P;
with Universe;
procedure P is
V: Universe. T := 10. 0;
begin
V := Universe. "*" ( V, 42. 0) ;
end P;
Use the use_type_clause. This makes only the operators in Universe directly visible.
with Universe;
procedure P is
V: Universe. T := 10. 0;
use type Universe. T;
begin
V := V * 42. 0;
end P;
There is a special beauty in the use_type_clause. Suppose you have a set of packages like
so:
with Universe;
package Pack is
subtype T is Universe. T;
end Pack;
with Pack;
procedure P is
V: Pack. T := 10. 0;
begin
V := V * 42. 0; --illegal
end P;
Now you've got into trouble. Since Universe is not made visible, you cannot use a use_-
package_clause for Universe to make the operator directly visible, nor can you use qualifi-
cation for the same reason. Also a use_package_clause for Pack does not help, since the
operator is not defined in Pack. The effect of the above construct means that the operator
is not nameable, i.e. it cannot be renamed in a renaming statement.
Of course you can add Universe to the context clause, but this may be impossible due to
some other reasons (e.g. coding standards); also adding the operators to Pack may be
forbidden or not feasible. So what to do?
140
The solution is simple. Use the use_type_clause for Pack.T and all is well!
with Pack;
procedure P is
V: Pack. T := 10. 0;
use type Pack. T;
begin
V := V * 42. 0;
end P;
A nested package is a package declared inside a package. Like a normal package, it has a
public part and a private part. From outside, items declared in a nested package N will
have visibility as usual; the programmer may refer to these items using a full dotted name
like P.N.X. (But not P.M.Y.)
package P is
D: Integer;
E: Integer;
private
--another nested package:
package M is
Y: Integer;
private
Bar: Integer;
end M;
end P;
Inside a package, declarations become visible as they are introduced, in textual order. That
is, a nested package N that is declared after some other declaration D can refer to this
declaration D. A declaration E following N can refer to items of N10 . But neither can “look
ahead” and refer to any declaration that goes after them. For example, spec N above cannot
refer to M in any way.
In the following example, a type is derived in both of the two nested packages Disks and
Books. Notice that the full declaration of parent type Item appears before the two nested
141
Packages
packages.
package Shelf is
pragma Elaborate_Body;
package Disks is
type Music is (
Jazz,
Rock,
Raga,
Classic,
Pop,
Soul) ;
end Disks;
package Books is
type Literature is (
Play,
Novel,
Poem,
Story,
Text,
Art) ;
end Books;
--shelf manipulation
private
142
--keeping private things private
package Boxes is
type Treasure( Identifier: ID) is limited private;
private
type Treasure( Identifier: ID) is new Item( Identifier) with null record;
end Boxes;
end Shelf;
A package may also be nested inside a subprogram. In fact, packages can be declared in any
declarative part, including those of a block.
Ada allows one to extend the functionality of a unit (package) with so-called children (child
packages). With certain exceptions, all the functionality of the parent is available to a child.
This means that all public and private declarations of the parent package are visible to all
child packages.
The above example, reworked as a hierarchy of packages, looks like this. Notice that the
package Ada is not needed by the top level package Shelf, hence its with clause doesn't
appear here. (We have added a match function for searching a shelf, though):
package Shelf is
pragma Elaborate_Body;
--shelf manipulation
end Shelf;
The name of a child package consists of the parent unit's name followed by the child
package's identifier, separated by a period (dot) ‘. '.
type Literature is (
Play,
143
Packages
Novel,
Poem,
Story,
Text,
Art) ;
Book has two components of type Unbounded_String, so Ada appears in a with clause of
the child package. This is unlike the nested packages case which requires that all units
needed by any one of the nested packages be listed in the context clause of the enclosing
package (see 10.1.2 Context Clauses - With Clauses ˆ{http://www.adaic.org/resources/
add_content/standards/05rm/html/RM-10-1-2.html} ). Child packages thus give better
control over package dependences. With clauses are more local.
The new child package Shelf.Disks looks similar. The Boxes package which was a nested
package in the private part of the original Shelf package is moved to a private child
package:
The privacy of the package means that it can only be used by equally private client units.
These clients include private siblings and also the bodies of siblings (as bodies are never
public).
Child packages may be listed in context clauses just like normal packages. A with of a child
also 'withs' the parent.
17.4.3 Subunits
A subunit is just a feature to move a body into a place of its own when otherwise the
enclosing body will become too large. It can also be used for limiting the scope of context
clauses.
The subunits allow to physically divide a package into different compilation units without
breaking the logical unity of the package. Usually each separated subunit goes to a different
file allowing separate compilation of each subunit and independent version control history
for each one.
144
package body Pack is
procedure Proc is separate;
end Pack;
with Some_Unit;
separate ( Pack)
procedure Proc is
begin
...
end Proc;
17.5 Notes
Notes
17.6.1 Wikibook
• Ada Programming11
17.6.2 Wikipedia
• Module12
• Annex 7: Packages13
• Annex 7: Packages14
11 http://en.wikibooks.org/wiki/Ada%20Programming
12 http://en.wikipedia.org/wiki/Module%20%28programming%29
13 http://www.adaic.org/resources/add_content/standards/95lrm/ARM_HTML/RM-7.html
14 http://www.adaic.org/resources/add_content/standards/05rm/html/RM-2-7.html
145
18 Input Output
18.1 Overview
Overview
The standard Ada libraries provide several Input/Output facilities, each one adapted to
specific needs. Namely, the language defines the following dedicated packages:
• Text_IO
• Sequential_IO
• Direct_IO
• Stream_IO
The programmer must choose the adequate package depending on the application needs.
For example, the following properties of the data handled by the application should be
considered:
• Data contents: plain text, or binary data?
• Accessing the data: random access, or sequential access?
• Medium: data file, console, network/data-bus?
• Data structure: homogeneous file (sequence of the same data field), heterogeneous file
(different data fields)?
• Data format: adherence to an existing data format, or the application can freely choose
a new one?
For example, Stream_IO is very powerful and can handle complex data structures but can
be heavier than other packages; Sequential_IO is lean and easy to use but cannot be used
by applications requiring random data access; Text_IO can handle just textual data, but it
is enough for handling the command-line console.
The following table gives some advices for choosing the more adequate one:
So the most important lesson to learn is choosing the right one. This chapter will describe
more in detail these standard packages, explaining how to use them effectively. Besides
these Ada-defined packages for general I/O operations each Ada compiler usually has other
147
Input Output
implementation-defined Input-Output facilities, and there are also other external libraries
for specialized I/O needs1 like XML processing or interfacing with databases.
Text I/O2 is probably the most used Input/Output package. All data inside the file are
represented by human readable text. Text I/O provides support for line and page layout
but the standard is free form text.
with Ada ;
use Ada ;
with Ada ;
use Ada ;
procedure Main is
Str : String ( 1.. 5) ;
Last : Natural;
begin
Ada. Text_IO. Get_Line ( Str, Last) ;
Ada. Text_IO. Put_Line ( Str ( 1.. Last) ) ;
end;
It also contains several generic packages for converting numeric and enumeration types to
character strings, or for handling Bounded and Unbounded strings, allowing the program-
mer to read and write different data types in the same file easily (there are ready-to-use
instantiations of these generic packages for the Integer, Float, and Complex types). Finally,
the same family of Ada.Text_IO packages (including the several children and instantiation
packages) for the type Wide_Character and Wide_Wide_Character.
It is worth noting that the family of Text_IO packages provide some automatic text
processing. For example, the Get_Line ignores white spaces at the beginning of a line
(Get_Immediate does not present this behavior), or adding a newline character when closing
the file. This is thus adequate for applications handling simple textual data, but users
requiring direct management of text (e.g. raw access to the character encoding) must
consider other packages like Sequential_IO.
Direct I/O is used for random access files which contain only elements of one specific type.
With Direct_IO you can position the file pointer to any element of that type (random access),
however you can't freely choose the element type, the element type needs to be a definite
subtype3 .
1 http://en.wikibooks.org/wiki/Ada%20Programming%23Other%20Language%20Libraries
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO
3 http://en.wikibooks.org/wiki/ada%20Programming%2FSubtypes%23definite_subtype
148
18.4 Sequential I/O
Sequential I/O
Direct I/O is used for random access files which contain only elements of one specific
type. With Sequential_IO it is the other way round: you can choose between definite4 and
indefinite5 element types but you have to read and write the elements one after the other.
Stream I/O is the most powerful input/output package which Ada provides. Stream I/O
allows you to mix objects from different element types in one sequential file. In order to
read/write from/to a stream each type provides a 'Read6 and 'Write7 attribute as well as
an 'Input8 and 'Output9 attribute. These attributes are automatically generated for each
type you declare.
The 'Read10 and 'Write11 attributes treat the elements as raw data. They are suitable for
low level input/output as well as interfacing with other programming languages.
The 'Input12 and 'Output13 attribute add additional control informations to the file, like for
example the 'First14 and 'Last15 attributes from an array.
In object orientated programming you can also use the 'Class16 'Input17 and 'Class18 'Output19
attributes - they will store and recover the actual object type as well.
Stream I/O is also the most flexible input/output package. All I/O attributes can be
replaced with user defined functions or procedures using representation clauses and you can
provide your own Stream I/O types using flexible object oriented techniques.
4 http://en.wikibooks.org/wiki/ada%20Programming%2FSubtypes%23definite_subtype
http://en.wikibooks.org/wiki/ada%20Programming%2FSubtypes%23Ada%20Programming%
5
2FSubtypes%23indefinite_subtype
6 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Read
7 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Write
8 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Input
9 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Output
10 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Read
11 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Write
12 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Input
13 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Output
14 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27First
15 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Last
16 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Class
17 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Input
18 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Class
19 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Output
149
Input Output
See also
18.6.1 Wikibook
• Ada Programming20
• Ada Programming/Libraries/Ada.Direct_IO21
• Ada Programming/Libraries/Ada.Sequential_IO22
• Ada Programming/Libraries/Ada.Streams23
• Ada Programming/Libraries/Ada.Streams.Stream_IO24
• Ada Programming/Libraries/Ada.Text_IO.Text_Streams25
• Ada Programming/Libraries/Ada.Text_IO26
• Ada Programming/Libraries/Ada.Text_IO.Enumeration_IO27 (nested package)
• Ada Programming/Libraries/Ada.Text_IO.Integer_IO28 (nested package)
• Ada Programming/Libraries/Ada.Text_IO.Modular_IO29 (nested package)
• Ada Programming/Libraries/Ada.Text_IO.Float_IO30 (nested package)
• Ada Programming/Libraries/Ada.Text_IO.Fixed_IO31 (nested package)
• Ada Programming/Libraries/Ada.Text_IO.Decimal_IO32 (nested package)
• Ada Programming/Libraries/Ada.Text_IO.Bounded_IO33
• Ada Programming/Libraries/Ada.Text_IO.Unbounded_IO34
• Ada Programming/Libraries/Ada.Text_IO.Complex_IO35 (specialized needs annex)
• Ada Programming/Libraries/Ada.Text_IO.Editing36 (specialized needs annex)
• Ada Programming/Libraries/Ada.Integer_Text_IO37
• Ada Programming/Libraries/Ada.Float_Text_IO38
• Ada Programming/Libraries/Ada.Complex_Text_IO39 (specialized needs annex)
• Ada Programming/Libraries/Ada.Storage_IO40 (not a general-purpose I/O package)
• Ada Programming/Libraries/Ada.IO_Exceptions41
• Ada Programming/Libraries/Ada.Command_Line42
20 http://en.wikibooks.org/wiki/Ada%20Programming
21 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Direct_IO
22 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Sequential_IO
23 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Streams
24 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Streams.Stream_IO
25 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Text_Streams
26 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Enumeration_
27
IO
28 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Integer_IO
29 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Modular_IO
30 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Float_IO
31 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Fixed_IO
32 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Decimal_IO
33 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Bounded_IO
34 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Unbounded_IO
35 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Complex_IO
36 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Editing
37 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Integer_Text_IO
38 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Float_Text_IO
39 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Complex_Text_IO
40 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Storage_IO
41 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.IO_Exceptions
42 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Command_Line
150
• Ada Programming/Libraries/Ada.Directories43
• Ada Programming/Libraries/Ada.Environment_Variables44
• Ada Programming/Libraries/GNAT.IO45 (implementation defined)
• Ada Programming/Libraries/GNAT.IO_Aux46 (implementation defined)
• Ada Programming/Libraries/GNAT.Calendar.Time_IO47 (implementation defined)
• Ada Programming/Libraries/System.IO48 (implementation defined)
• Ada Programming/Libraries49
• Ada Programming/Libraries/GUI50
• Ada Programming/Libraries/Web51
• Ada Programming/Libraries/Database52
• Ada Programming/Platform53
• Ada Programming/Platform/Linux54
• Ada Programming/Platform/Windows55
43 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Directories
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Environment_
44
Variables
45 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.IO
46 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.IO_Aux
47 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Calendar.Time_IO
48 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FSystem.IO
49 Chapter 40 on page 331
50 Chapter 48 on page 361
51 Chapter 51 on page 371
52 Chapter 50 on page 365
53 Chapter 53 on page 375
54 Chapter 54 on page 377
55 Chapter 55 on page 379
151
Input Output
152
19 Exceptions
19.1 Robustness
Robustness
153
Exceptions
• A unit (e.g., block or subprogram body) may raise an exception, to signal that an anomaly
has been detected. The computation that raised the exception is abandoned (and can
never be resumed, although it can be restarted).
• A unit may propagate an exception that has been raised by itself (or propagated out of
another unit it has called).
• A unit may alternatively handle such an exception, allowing programmer-defined recovery
from an anomalous situation. Exception handlers are segregated from normal-case code.
The predefined exceptions are those defined in package Standard . Every language-defined
run-time error causes a predefined exception to be raised. Some examples are:
• Constraint_Error, raised when a subtype’s constraint is not satisfied
• Program_Error, when a protected operation is called inside a protected object, e.g.
• Storage_Error, raised by running out of storage
• Tasking_Error, when a task cannot be activated because the operating system has not
enough resources, e.g.
Ex.1
Ex.2
loop
P := new Int_Node'(0, P);
end loop; --Soon raises Storage_Error,
--because of the extreme memory leak.
154
...
...
A negative argument to Sqrt now raises Constraint_Error at the point of call. Sqrt is never
even entered.
155
Exceptions
Input-output exceptions
declare
A : Matrix (1 .. M, 1 .. N);
begin
for I in 1 .. M loop
for J in 1 .. N loop
begin
Get (A(I,J));
exception
when Data_Error =>
Put ("Ill-formed matrix element");
A(I,J) := 0.0;
end;
end loop;
end loop;
exception
when End_Error =>
Put ("Matrix element(s) missing");
end;
Exceptions are declared rather like objects, but they are not objects. For example, recursive
re-entry to a scope where an exception is declared does not create a new exception of the
same name; instead the exception declared in the outer invocation is reused.
Ex.1
Line_Failed : exception;
Ex.2
package Directory_Enquiries is
156
Corr_Number : out Number);
Name_Duplicated : exception;
Name_Absent : exception;
Directory_Full : exception;
end Directory_Enquiries;
end Directory_Enquiries;
Exception handlers may be grouped at the end of a block, subprogram body, etc. A handler
is any sequence of statements that may end:
157
Exceptions
• by completing;
• by executing a return statement;
• by raising a different exception (raise e;);
• by re-raising the same exception (raise;).
Suppose that an exception e is raised in a sequence of statements U (a block, subprogram
body, etc.).
• If U contains a handler for e: that handler is executed, then control leaves U.
• If U contains no handler for e: e is propagated out of U; in effect, e is raised at the "point
of call” of U.
So the raising of an exception causes the sequence of statements responsible to be abandoned
at the point of occurrence of the exception. It is not, and cannot be, resumed.
Ex. 1
...
exception
when Line_Failed =>
begin --attempt recovery
Log_Error;
Retransmit (Current_Packet);
exception
when Line_Failed =>
Notify_Engineer; --recovery failed!
Abandon_Call;
end;
...
158
Put_Line (Exception_Information(Error));
end;
The exception message content is implementation defined when it is not set by the user who
raises the exception. It usually contains a reason for the exception and the raising location.
The user can specify a message using the procedure Raise_Exception.
declare
Valve_Failure : exception;
begin
...
Raise_Exception (Valve_Failure'Identity, "Failure while opening");
...
Raise_Exception (Valve_Failure'Identity, "Failure while closing");
...
exception
when Fail: Valve_Failure =>
Put (Exception_Message (Fail));
end;
Starting with Ada 2005, a simpler syntax can be used to associate a string message with
exception occurrence.
The Ada.Exceptions package also provides subprograms for saving exception occurrences
and re-raising them.
19.9.1 Wikibook
• Ada Programming1
1 http://en.wikibooks.org/wiki/Ada%20Programming
159
Exceptions
160
20 Generics
The idea of code reuse arises from the necessity for constructing large software systems
combining well-established building blocks. The reusability of code improves the productivity
and the quality of software. The generic units are one of the ways in which the Ada language
supports this characteristic. A generic unit is a subprogram or package that defines algorithms
in terms of types and operations that are not defined until the user instantiates them.
Note to C++ programmers: generic units are similar to C++ templates.
For example, to define a procedure for swapping variables of any (non-limited) type:
generic
type Element_T is private; --Generic formal type parameter
procedure Swap (X, Y : in out Element_T);
Now the Swap_Integers procedure can be used for variables of type Integer.
The generic procedure can be instantiated for all the needed types. It can be instantiated
with different names or, if the same identifier is used in the instantiation, each declaration
overloads the procedure:
161
Generics
Similarly, generic packages can be used, for example, to implement a stack of any kind of
elements:
generic
Max: Positive;
type Element_T is private;
package Generic_Stack is
procedure Push (E: Element_T);
function Pop return Element_T;
end Generic_Stack;
declare
package Float_100_Stack is new Generic_Stack (100, Float);
use Float_100_Stack;
begin
Push (45.8);
--...
end;
The generic unit declares generic formal parameters, which can be:
• objects (of mode in or in out but never out)
• types
• subprograms
• instances of another, designated, generic unit.
When instantiating the generic, the programmer passes one actual parameter for each formal.
Formal values and subprograms can have defaults, so passing an actual for them is optional.
Formal parameters of mode in accept any value, constant, or variable of the designated
type. The actual is copied into the generic instance, and behaves as a constant inside the
generic; this implies that the designated type cannot be limited. It is possible to specify a
162
default value, like this:
generic
Object : in Natural := 0;
generic
Size : in Natural := 0;
package P is
type T1 is mod Size; --illegal!
type T2 is range 1 .. Size; --illegal!
type T3 is new Integer range 1 .. Size; --OK
subtype T4 is Integer range 1 .. Size; --OK
end P;
The reason why formal objects are nonstatic is to allow the compiler to emit the object code
for the generic only once, and to have all instances share it, passing it the address of their
actual object as a parameter. This bit of compiler technology is called shared generics. If
formal objects were static, the compiler would have to emit one copy of the object code,
with the object embedded in it, for each instance, potentially leading to an explosion in
object code size (code bloat).
(Note to C++ programmers: in C++, since formal objects can be static, the compiler cannot
implement shared generics in the general case; it would have to examine the entire body of
the generic before deciding whether or not to share its object code. In contrast, Ada generics
are designed so that the compiler can instantiate a generic without looking at its body.)
The syntax allows the programmer to specify which type categories are acceptable as actuals.
As a rule of thumb: The syntax expresses how the generic sees the type, i.e. it assumes the
worst, not how the creator of the instance sees the type.
This is the syntax of RM 12.5:
formal_type_declaration ::=
type defining_identifier[discriminant_part] is
formal_type_definition;
163
Generics
| formal_array_type_definition
| formal_access_type_definiton
| formal_interface_type_definition
This is quite complex, so some examples are given below. A type declared with the syntax
type T (<>) denotes a type with unknown discriminants. This is the Ada vernacular for
indefinite types, i.e. types for which objects cannot be declared without giving an initial
expression. An example of such a type is one with a discriminant without default, another
example is an unconstrained array type.
164
Generic formal type Acceptable actual types
type T is (<>); Any discrete type: integer3 , modular4 ,
or enumeration5 .
type T is range <>; Any signed integer type
type T is mod <>; Any modular type
type T is delta <>; Any (non-decimal) fixed point type6
type T is delta <> digits <>; Any decimal fixed point type
type T is digits <>; Any floating point type7
type T is array (I) of E; Any array type8 with index of type I
and elements of type E (I and E could be
formal parameters as well)
type T is access O; Any access type9 pointing to objects of
type O (O could be a formal parameter as
well)
In the body we can only use the operations predefined for the type category of the formal
parameter. That is, the generic specification is a contract between the generic implementor
and the client instantiating the generic unit. This is different to the parametric features of
other languages, such as C++.
It is possible to further restrict the set of acceptable actual types like so:
3 Chapter 6 on page 69
4 Chapter 7 on page 71
5 Chapter 8 on page 73
6 Chapter 10 on page 79
7 Chapter 9 on page 77
8 Chapter 11 on page 83
9 Chapter 13 on page 99
165
Generics
Here is the specification of a generic subprogram that takes another subprogram as its
parameter:
generic
type Element_T is private;
with function "*" (X, Y: Element_T) return Element_T;
function Square (X : Element_T) return Element_T;
And here is the body of the generic subprogram; it calls parameter as it would any other
subprogram.
This generic function could be used, for example, with matrices, having defined the matrix
product.
with Square;
with Matrices;
procedure Matrix_Example is
function Square_Matrix is new Square
(Element_T => Matrices.Matrix_T, "*" => Matrices.Product);
A : Matrices.Matrix_T := Matrices.Identity;
begin
A := Square_Matrix (A);
end Matrix_Example;
It is possible to specify a default with "the box" (is <> ), like this:
generic
type Element_T is private;
with function "*" (X, Y: Element_T) return Element_T is <>;
This means that if, at the point of instantiation, a function "*" exists for the actual type,
and if it is directly visible, then it will be used by default as the actual subprogram.
One of the main uses is passing needed operators. The following example shows this (follow
download links for full example):
File: Algorithms/binary_search.adb
generic
type Element_Type is private;
...
with function "<"
(Left : in Element_Type;
Right : in Element_Type)
return Boolean
166
is <> ;
procedure Search
(Elements : in Array_Type;
Search : in Element_Type;
Found : out Boolean;
Index : out Index_Type'Base)
...
A generic formal can be a package; it must be an instance of a generic package, so that the
generic knows the interface exported by the package:
generic
with package P is new Q (<> );
This means that the actual must be an instance of the generic package Q. The box after Q
means that we do not care which actual generic parameters were used to create the actual
for P. It is possible to specify the exact parameters, or to specify that the defaults must be
used, like this:
generic
--P1 must be an instance of Q with the specified actual parameters:
with package P1 is new Q (Param1 => X, Param2 => Y);
It is all or nothing: if you specify the generic parameters, you must specify all of them.
Similarly, if you specify no parameters and no box, then all the generic formal parameters of
Q must have defaults. The actual package must, of course, match these constraints.
The generic sees both the public part and the generic parameters of the actual package
(Param1 and Param2 in the above example).
This feature allows the programmer to pass arbitrarily complex types as parameters to a
generic unit, while retaining complete type safety and encapsulation. (example needed)
It is not possible for a package to list itself as a generic formal, so no generic recursion is
possible. The following is illegal:
with A;
generic
with package P is new A (<> );
package A; --illegal: A references itself
167
Generics
A generic unit can be nested inside another unit, which itself may be generic. Even though
no special rules apply (just the normal rules about generics and the rules about nested
units), novices may be confused. It is important to understand the difference between a
generic unit and instances of a generic unit.
Example 1. A generic subprogram nested in a nongeneric package.
168
package Bag_Of_Strings is
type Bag is private;
generic
with procedure Operator (S : in out String);
procedure Apply_To_All (B : in out Bag);
private
--omitted
end Bag_Of_Strings;
To use Apply_To_All, you first define the procedure to be applied to each String in the
Bag. Then, you instantiate Apply_To_All, and finally you call the instance.
with Bag_Of_Strings;
procedure Example_1 is
procedure Capitalize (S : in out String) is separate; --omitted
procedure Capitalize_All is
new Bag_Of_Strings.Apply_To_All (Operator => Capitalize);
B : Bag_Of_Strings.Bag;
begin
Capitalize_All (B);
end Example_1;
generic
type Element_Type (<>) is private;
package Generic_Bag is
type Bag is private;
generic
with procedure Operator (S : in out Element_Type);
procedure Apply_To_All (B : in out Bag);
private
--omitted
end Generic_Bag;
As you can see, the generic formal subprogram Operator takes a parameter of the generic
formal type Element_Type. This is okay: the nested generic sees everything that is in its
enclosing unit.
You cannot instantiate Generic_Bag.Apply_To_All directly, so you must first
create an instance of Generic_Bag, say Bag_Of_Strings, and then instantiate
Bag_Of_Strings.Apply_To_All.
with Generic_Bag;
procedure Example_2 is
procedure Capitalize (S : in out String) is separate; --omitted
package Bag_Of_Strings is
new Generic_Bag (Element_Type => String);
procedure Capitalize_All is
new Bag_Of_Strings.Apply_To_All (Operator => Capitalize);
B : Bag_Of_Strings.Bag;
begin
169
Generics
Capitalize_All (B);
end Example_2;
package Bag_Of_Strings is
type Bag is private;
private
--omitted
end Bag_Of_Strings;
generic
with procedure Operator (S : in out String);
procedure Bag_Of_Strings.Apply_To_All (B : in out Bag);
generic
type Element_Type (<>) is private;
package Generic_Bag is
type Bag is private;
private
170
--omitted
end Generic_Bag;
generic
with procedure Operator (S : in out Element_Type);
procedure Generic_Bag.Apply_To_All (B : in out Bag);
with Generic_Bag.Apply_To_All;
procedure Example_4 is
procedure Capitalize (S : in out String) is separate; --omitted
package Bag_Of_Strings is
new Generic_Bag (Element_Type => String);
procedure Capitalize_All is
new Bag_Of_Strings.Apply_To_All (Operator => Capitalize);
B : Bag_Of_Strings.Bag;
begin
Capitalize_All (B);
end Example_4;
generic
type Element_Type (<>) is private;
type Hash_Type is (<>);
with function Hash_Function (E : Element_Type) return Hash_Type;
package Generic_Hash_Map is
type Map is private;
private
--omitted
end Generic_Hash_Map;
Suppose we want a child of a Generic_Hash_Map that can serialise the map to disk;
for this it needs to sort the map by hash value. This is easy to do, because we know that
Hash_Type is a discrete type, and so has a less-than operator. The child unit that does
the serialisation does not need any additional generic parameters, but it must be generic
nevertheless, so it can see its parent's generic parameters, public and private part.
generic
package Generic_Hash_Map.Serializer is
procedure Dump (Item : in Map; To_File : in String);
procedure Restore (Item : out Map; From_File : in String);
end Generic_Hash_Map.Serializer;
To read and write a map to disk, you first create an instance of Generic_Hash_Map,
for example Map_Of_Unbounded_Strings, and then an instance of Map_Of_-
Unbounded_Strings.Serializer:
171
Generics
with Ada.Strings.Unbounded;
with Generic_Hash_Map.Serializer;
procedure Example_5 is
use Ada.Strings.Unbounded;
function Hash (S : in Unbounded_String) return Integer is separate; --omitted
package Map_Of_Unbounded_Strings is
new Generic_Hash_Map (Element_Type => Unbounded_String,
Hash_Type => Integer,
Hash_Function => Hash);
package Serializer is
new Map_Of_Unbounded_Strings.Serializer;
M : Map_Of_Unbounded_Strings.Map;
begin
Serializer.Restore (Item => M, From_File => "map.dat");
end Example_5;
20.5.1 Wikibook
• Ada Programming10
• Ada Programming/Object Orientation11 : tagged types provides other mean of polymor-
phism in Ada.
20.5.2 Wikipedia
• Generic programming12
10 http://en.wikibooks.org/wiki/Ada%20Programming
11 Chapter 22 on page 187
12 http://en.wikipedia.org/wiki/Generic%20programming
13 http://es.wikibooks.org/wiki/Programaci%F3n%20en%20Ada%2FUnidades%20gen%E9ricas
172
21 Tasking
21.1 Tasks
Tasks
A task unit is a program unit that is obeyed concurrently with the rest of an Ada program.
The corresponding activity, a new locus of control, is called a task in Ada terminology, and
is similar to a thread, for example in Java Threads1 . The execution of the main program is
also a task, the anonymous environment task. A task unit has both a declaration and a
body, which is mandatory. A task body may be compiled separately as a subunit, but a task
may not be a library unit, nor may it be generic. Every task depends on a master, which is
the immediately surrounding declarative region - a block, a subprogram, another task, or a
package. The execution of a master does not complete until all its dependent tasks have
terminated. The environment task is the master of all other tasks; it terminates only when
all other tasks have terminated.
Task units are similar to packages in that a task declaration defines entities exported from
the task, whereas its body contains local declarations and statements of the task.
A single task is declared as follows:
task Single is
declarations of exported identifiers
end Single;
...
task body Single is
local declarations and statements
end Single;
task No_Exports;
Ex. 1
procedure Housekeeping is
task Check_CPU;
task Backup_Disk;
1 http://en.wikibooks.org/wiki/Java%3AThreads
173
Tasking
It is possible to declare task types, thus allowing task units to be created dynamically, and
incorporated in data structures:
task type T is
...
end T;
...
Task_1, Task_2 : T;
...
task body T is
...
end T;
Task types are limited, i.e. they are restricted in the same way as limited private types, so
assignment and comparison are not allowed.
21.1.1 Rendezvous
The only entities that a task may export are entries. An entry looks much like a procedure.
It has an identifier and may have in, out or in out parameters. Ada supports communication
from task to task by means of the entry call. Information passes between tasks through
the actual parameters of the entry call. We can encapsulate data structures within tasks
and operate on them by means of entry calls, in a way analogous to the use of packages for
encapsulating variables. The main difference is that an entry is executed by the called task,
not the calling task, which is suspended until the call completes. If the called task is not
ready to service a call on an entry, the calling task waits in a (FIFO) queue associated with
the entry. This interaction between calling task and called task is known as a rendezvous.
The calling task requests rendezvous with a specific named task by calling one of its entries. A
task accepts rendezvous with any caller of a specific entry by executing an accept statement
for the entry. If no caller is waiting, it is held up. Thus entry call and accept statement
behave symmetrically. (To be honest, optimized object code may reduce the number of
context switches below the number implied by this naive description.)
Ex. 2 The following task type implements a single-slot buffer, i.e. an encapsulated variable
that can have values inserted and removed in strict alternation. Note that the buffer
task has no need of state variables to implement the buffer protocol: the alternation of
insertion and removal operations is directly enforced by the control structure in the body of
Encapsulated_Buffer_Task_Type which is, as is typical, a loop.
174
task type Encapsulated_Buffer_Task_Type is
entry Insert (An_Item : in Item);
entry Remove (An_Item : out Item);
end Encapsulated_Buffer_Task_Type;
...
Buffer_Pool : array (0 .. 15) of Encapsulated_Buffer_Task_Type;
This_Item : Item;
...
task body Encapsulated_Buffer_Task_Type is
Datum : Item;
begin
loop
accept Insert (An_Item : in Item) do
Datum := An_Item;
end Insert;
accept Remove (An_Item : out Item) do
An_Item := Datum;
end Remove;
end loop;
end Encapsulated_Buffer_Task_Type;
...
Buffer_Pool(1).Remove (This_Item);
Buffer_Pool(2).Insert (This_Item);
To avoid being held up when it could be doing productive work, a server task often needs
the freedom to accept a call on any one of a number of alternative entries. It does this by
means of the selective wait statement, which allows a task to wait for a call on any of two or
more entries.
If only one of the alternatives in a selective wait statement has a pending entry call, then
that one is accepted. If two or more alternatives have calls pending, the implementation is
free to accept any one of them. For example, it could choose one at random. This introduces
bounded non-determinism into the program. A sound Ada program should not depend on a
particular method being used to choose between pending entry calls. (However, there are
facilities to influence the method used, when that is necessary.)
Ex. 3
175
Tasking
x, y : Encapsulated_Variable_Task_Type;
it : Item;
...
x.Store(Some_Expression);
...
x.Fetch (it);
y.Store (it);
Again, note that the control structure of the body ensures that an Encapsulated_Variable_-
Task_Type must be given an initial value by a first Store operation before any Fetch
operation can be accepted.
21.1.3 Guards
Depending on circumstances, a server task may not be able to accept calls for some of
the entries that have accept alternatives in a selective wait statement. The acceptance of
any alternative can be made conditional by using a guard, which is Boolean2 precondition
for acceptance. This makes it easy to write monitor-like server tasks, with no need for an
explicit signaling mechanism, nor for mutual exclusion. An alternative with a True guard is
said to be open. It is an error if no alternative is open when the selective wait statement is
executed, and this raises the Program_Error exception.
Ex. 4
task Cyclic_Buffer_Task_Type is
entry Insert (An_Item : in Item);
entry Remove (An_Item : out Item);
end Cyclic_Buffer_Task_Type;
...
task body Cyclic_Buffer_Task_Type is
Q_Size : constant := 100;
subtype Q_Range is Positive range 1 .. Q_Size;
Length : Natural range 0 .. Q_Size := 0;
Head, Tail : Q_Range := 1;
Data : array (Q_Range) of Item;
begin
loop
select
when Length < Q_Size =>
accept Insert (An_Item : in Item) do
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FTypes%23Boolean
176
Data(Tail) := An_Item;
end Insert;
Tail := Tail mod Q_Size + 1;
Length := Length + 1;
or
when Length > 0 =>
accept Remove (An_Item : out Item) do
An_Item := Data(Head);
end Remove;
Head := Head mod Q_Size + 1;
Length := Length - 1;
end select;
end loop;
end Cyclic_Buffer_Task_Type;
Tasks allow for encapsulation and safe usage of variable data without the need for any
explicit mutual exclusion and signaling mechanisms. Ex. 4 shows how easy it is to write
server tasks that safely manage locally-declared data on behalf of multiple clients. There is
no need for mutual exclusion of access to the managed data, because it is never accessed
concurrently. However, the overhead of creating a task merely to serve up some data may be
excessive. For such applications, Ada 95 provides protected modules. A protected module
encapsulates a data structure and exports subprograms that operate on it under automatic
mutual exclusion. It also provides automatic, implicit signaling of conditions between client
tasks. Again, a protected module can be either a single protected object or a protected type,
allowing many protected objects to be created.
A protected module can export only procedures, functions and entries, and its body may
contain only the bodies of procedures, functions and entries. The protected data is declared
after private in its specification, but is accessible only within the protected module's
body. Protected procedures and entries may read and/or write its encapsulated data, and
automatically exclude each other. Protected functions may only read the encapsulated data,
so that multiple protected function calls can be concurrently executed in the same protected
object, with complete safety; but protected procedure calls and entry calls exclude protected
function calls, and vice versa. Exported entries and subprograms of a protected object are
executed by its calling task, as a protected object has no independent locus of control. (To
be honest, optimized object code may reduce the number of context switches below the
number implied by this naive description.)
Like a task entry, a protected entry can employ a guard to control admission. This provides
automatic signaling, and ensures that when a protected entry call is accepted, its guard
condition is True, so that a guard provides a reliable precondition for the entry body.
Ex. 5 The following is a simple protected type analogous to the Encapsulated_Buffer task
in Ex. 2.
177
Tasking
Note how the guards, using the state variable Empty, ensure that messages are alternately
inserted and removed, and that no attempt can be made to take data from an empty buffer.
All this is achieved without explicit signaling or mutual exclusion constructs, whether in the
calling task or in the protected type itself.
The notation for calling a protected entry or procedure is exactly the same as that for calling
a task entry. This makes it easy to replace one implementation of the abstract type by the
other, the calling code being unaffected.
Ex. 6 The following task type implements Dijkstra's semaphore ADT, with FIFO scheduling
of resumed processes. The algorithm will accept calls to both Wait and Signal, so long as
the semaphore invariant would not be violated. When that circumstance approaches, calls
to Wait are ignored for the time being.
178
end loop;
end Semaphore_Task_Type;
Unlike the task type above, this does not ensure that Initialize is called before Wait or
Signal, and Count is given a default initial value instead. Restoring this defensive feature of
the task version is left as an exercise for the reader.
179
Tasking
Entry families
Sometimes we need a group of related entries. Entry families, indexed by a discrete type3 ,
meet this need.
Ex. 8 This task provides a pool of several buffers.
Note that the busy wait else null is necessary here to prevent the task from being suspended
on some buffer when there was no call pending for it, because such suspension would delay
serving requests for all the other buffers (perhaps indefinitely).
21.4 Termination
Termination
Server tasks often contain infinite loops to allow them to service an arbitrary number of
calls in succession. But control cannot leave a task's master until the task terminates, so
we need a way for a server to know when it should terminate. This is done by a terminate
alternative in a selective wait.
3 http://en.wikibooks.org/wiki/ada%20Programming%2FTypes%23List%20of%20Types
180
Ex. 9
21.5 Timeout
Timeout
A task may need to avoid being held up by calling to a slow server. A timed entry call lets a
client specify a maximum delay before achieving rendezvous, failing which the attempted
entry call is withdrawn and an alternative sequence of statements is executed.
Ex. 10
task Password_Server is
entry Check (User, Pass : in String; Valid : out Boolean);
entry Set (User, Pass : in String);
end Password_Server;
...
User_Name, Password : String (1 .. 8);
...
181
Tasking
To time out the functionality provided by a task, two distinct entries are needed: one to
pass in arguments, and one to collect the result. Timing out on rendezvous with the latter
achieves the desired effect.
Ex. 11
task Process_Data is
entry Input (D : in Datum);
entry Output (D : out Datum);
end Process_Data;
loop
collect Input_Data from sensors;
Process_Data.Input (Input_Data);
select
Process_Data.Output (Output_Data);
pass Output_Data to display task;
or
delay 0.1;
Log_Error ("Processing did not complete quickly enough.");
end select;
end loop;
task Resource_Lender is
entry Get_Loan (Period : in Duration);
entry Give_Back;
end Resource_Lender;
...
task body Resource_Lender is
Period_Of_Loan : Duration;
begin
loop
select
accept Get_Loan (Period : in Duration) do
Period_Of_Loan := Period;
end Get_Loan;
select
accept Give_Back;
or
delay Period_Of_Loan;
Log_Error ("Borrower did not give up loan soon
182
enough.");
end select;
or
terminate;
end select;
end loop;
end Resource_Lender;
An entry call can be made conditional, so that it is withdrawn if the rendezvous is not immedi-
ately achieved. This uses the select statement notation with an else part. Thus the constructs
select
Callee.Rendezvous;
else
Do_something_else;
end select;
and
select
Callee.Rendezvous;
or
delay 0.0;
Do_something_else;
end select;
seem to be conceptually equivalent. However, the attempt to start the rendezvous may
take some time, especially if the callee is on another processor, so the delay 0.0; may expire
although the callee would be able to accept the rendezvous, whereas the else construct is
safe.
21.8 Scheduling
183
Tasking
Scheduling
21.9 Interfaces
Interfaces
21.10.1 Wikibook
• Ada Programming5
• Ada Programming/Libraries/Ada.Storage_IO6
Ada 95
Ada 2005
4 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Finterface
5 http://en.wikibooks.org/wiki/Ada%20Programming
6 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Storage_IO
184
• Section 9: Tasks and Synchronization ˆ{http://www.adaic.org/resources/add_
content/standards/05rm/html/RM-9.html}
7 http://www.adaic.org/docs/95style/html/sec_6/toc.html
8 http://es.wikibooks.org/wiki/Programaci%F3n%20en%20Ada%2FTareas
185
22 Object Orientation
187
Object Orientation
package Directory is
function Present (Name_Pattern: String) return Boolean;
generic
with procedure Visit (Full_Name, Phone_Number, Address: String;
Stop: out Boolean);
procedure Iterate (Name_Pattern: String);
end Directory;
The Directory is an object consisting of data (the telephone numbers and addresses, presum-
ably held in an external file or database) and behavior (it can look an entry up and traverse
all the entries matching a Name_Pattern, calling Visit on each).
A simple package provides for encapsulation (the inner workings of the directory are hidden)
and a pair of subprograms provide the behavior.
This pattern is appropriate when only one object of a certain type must exist; there is,
therefore, no need for type extension or polymorphism.
package P is
type A is tagged private;
type B is private;
procedure Proc (This: A; That: B); --primitive on A and B
end P;
Type derivation has been part of Ada since the very start.
package P is
type T is private;
function Create (Data: Boolean) return T; --primitive
procedure Work (Object : in out T); --primitive
procedure Work (Pointer: access T); --primitive
188
type Acc_T is access T;
procedure Proc (Pointer: Acc_T); --not primitive
private
type T is record
Data: Boolean;
end record;
end P;
The above example creates a type T that contains data (here just a Boolean but it could be
anything) and behavior consisting of some subprograms. It also demonstrates encapsulation
by placing the details of the type T in the private part of the package.
The primitive operations of T are the function Create, the overloaded procedures
Work, and the predefined "=" operator; Proc is not primitive, since it has an ac-
cess type on T as parameter — don't confuse this with an access parameter, as used
in the second procedure Work. When deriving from T, the primitive operations are inherited.
with P;
package Q is
type Derived is new P.T;
end Q;
The type Q.Derived has the same data and the same behavior as P.T; it inherits both the
data and the subprograms. Thus it is possible to write:
with Q;
procedure Main is
Object: Q.Derived := Q.Create (Data => False);
begin
Q.Work (Object);
end Main;
Admittedly, the reasons for writing this may seem obscure. The purpose of this kind of code
is to have objects of types P.T and Q.Derived, which are not compatible:
Ob1: P.T;
Ob2: Q.Derived;
This feature is not used very often (it's used e.g. for declaring types reflecting physical
dimensions) but I present it here to introduce the next step: type extension.
189
Object Orientation
package Person is
type Object is tagged
record
Name : String (1 .. 10);
Gender : Gender_Type;
end record;
procedure Put (O : Object);
end Person;
As you can see, a Person.Object is an object in the sense that it has data and behavior
(the procedure Put). However, this object does not hide its data; any program unit
that has a with Person clause can read and write the data in a Person.Object directly.
This breaks encapsulation and also illustrates that Ada completely separates the con-
cepts of encapsulation and type. Here is a version of Person.Object that encapsulates its data:
package Person is
type Object is tagged private;
procedure Put (O : Object);
private
type Object is tagged
record
Name : String (1 .. 10);
Gender : Gender_Type;
end record;
end Person;
Because the type Person.Object is tagged, it is possible to create a record extension, which
is a derived type with additional data.
with Person;
package Programmer is
type Object is new Person.Object with private;
private
type Object is new Person.Object with
record
Skilled_In : Language_List;
end record;
end Programmer;
The type Programmer.Object inherits the data and behavior, i.e. the type's primitive
operations, from Person.Object; it is thus possible to write:
with Programmer;
procedure Main is
Me : Programmer.Object;
begin
Programmer.Put (Me);
Me.Put; --equivalent to the above, Ada 2005 only
end Main;
190
Like in the case of untagged types, objects of type Person and Programmer are convertible.
However, where untagged objects are convertible in either direction, conversion of tagged
types only works in the direction to the root. (Conversion away from the root would have
to add components out of the blue.) Such a conversion is called a view conversion, because
components are not lost, they only become invisible.
Extension aggregates have to be used if you go away from the root.
22.1.5 Overriding
Now that we have introduced tagged types, record extensions and primitive operations,
it becomes possible to understand overriding. In the examples above, we introduced
a type Person.Object with a primitive operation called Put. Here is the body of the package:
with Ada.Text_IO;
package body Person is
procedure Put (O : Object) is
begin
Ada.Text_IO.Put (O.Name);
Ada.Text_IO.Put (" is a ");
Ada.Text_IO.Put_Line (Gender_Type'Image (O.Gender));
end Put;
end Person;
As you can see, this simple operation prints both data components of the record type to
standard output. Now, remember that the record extension Programmer.Object has an
additional data member. If we write:
with Programmer;
procedure Main is
Me : Programmer.Object;
begin
Programmer.Put (Me);
Me.Put; --equivalent to the above, Ada 2005 only
end Main;
then the program will call the inherited primitive operation Put, which will print the name
and gender but not the additional data. In order to provide this extra behavior, we must
override the inherited procedure Put like this:
with Person;
package Programmer is
type Object is new Person.Object with private;
overriding --Optional keyword, new in Ada 2005
procedure Put (O : Object);
private
type Object is new Person.Object with
record
Skilled_In : Language_List;
end record;
end Programmer;
191
Object Orientation
declare
Someone : Person.Object'Class := ...; --to be expanded later
begin
Someone.Put; --dynamic dispatching
end;
192
The declaration of Someone denotes an object that may be of either type, Person.Object
or Programmer.Object. Consequently, the call to the primitive operation Put dispatches
dynamically to either Person.Put or Programmer.Put.
The only problem is that, since we don't know whether Someone is a programmer or not,
we don't know how many data components Someone has, either, and therefore we don't
know how many bytes Someone takes in memory. For this reason, the class-wide type
Person.Object'Class is indefinite1 . It is impossible to declare an object of this type
without giving some constraint. It is, however, possible to:
• declare an object of a class-wide with an initial value (as above). The object is then
constrained by its initial value.
• declare an access value to such an object (because the access value has a known size);
• pass objects of a class-wide type as parameters to subprograms
• assign an object of a specific type (in particular, the result of a function call) to a variable
of a class-wide type.
With this knowledge, we can now build a polymorphic collection of persons; in this example
we will quite simply create an array of access values to persons:
with Person;
procedure Main is
type Person_Access is access Person.Object'Class;
type Array_Of_Persons is array (Positive range <>) of Person_Access;
The above procedure achieves our desired goal: it traverses the array of Persons and calls
the procedure Put that is appropriate for each person.
You don't need to know how dynamic dispatching works in order to use it effectively but, in
case you are curious, here is an explanation.
The first component of each object in memory is the tag; this is why objects are of a tagged
type rather than plain records. The tag really is an access value to a table; there is one table
for each specific type. The table contains access values to each primitive operation of the
type. In our example, since there are two types Person.Object and Programmer.Object,
there are two tables, each containing a single access value. The table for Person.Object
contains an access value to Person.Put and the table for Programmer.Object contains an
access value to Programmer.Put. When you compile your program, the compiler constructs
both tables and places them in the program executable code.
1 http://en.wikibooks.org/wiki/ada%20Programming%2FSubtypes%23Indefinite_subtype
193
Object Orientation
Each time the program creates a new object of a specific type, it automatically sets its tag
to point to the appropriate table.
Each time the program calls a primitive operation, the compiler inserts object code that:
• dereferences the tag to find the table of primitive operations for the specific type of the
object at hand
• dereferences the access value to the primitive operation
• calls the primitive operation.
When you perform a view conversion to an ancestor type, the compiler performs these two
dereferences at compile time rather than run time: this is static dispatching; the compiler
emits code that directly calls the primitive operation of the ancestor type specified in the
view conversion.
Redispatching
Dispatching works on the (hidden) tag of the object. So what happens when a primitive
operation Op1 calls another primitive operation Op2? Which operation will be called when
Op1 is called by dispatching?
D: Derived;
C: Root'Class := D;
In this fragment, Op1 is not overridden, whereas Op2 is overridden. The body of Op1 calls
Op2, thus which Op2 will be called for a call of Op1 with a parameter of type Derived?
The answer is: Ada gives complete control over dispatching and redispatching. If you want
redispatching, it has to be required explicitly by converting the parameter to the class-wide
type again. (Remember: View conversions never lose components, they just hide them. A
conversion to the class-wide type makes them visible again.)
Thus the first call of Op1 (statically linked, i.e. not dispatching) calls the inherited Op1
— and within Op1, the first call to Op2 is therefore also a static call to the inherited Op2
(there is no redispatching). However the second call, since the parameter R is converted to
the class-wide type, dispatches to the overriding Op2.
194
The second call of Op1 is a dispatching call to the inherited Op1 and behaves exactly as the
first.
To understand what happens here, the implicitly defined inherited Op1 is just the parent
operation called with a view conversion of the parameter:
Run-time type identification allows the program to (indirectly or directly) query the tag of
an object at run time to determine which type the object belongs to. This feature, obviously,
makes sense only in the context of polymorphism and dynamic dispatching, so works only
on tagged types.
You can determine whether an object belongs to a certain class of types, or to a specific
type, by means of the membership test in, like this:
...
procedure Explicit_Dispatch (This : in Base'Class) is
begin
if This in Leaf then ... end if;
if This in Derived'Class then ... end if;
end Explicit_Dispatch;
Thanks to the strong typing rules of Ada, run-time type identification is in fact rarely
needed; the distinction between class-wide and specific types usually allows the programmer
to ensure objects are of the appropriate type without resorting to this feature.
Additionally, the reference manual defines package Ada.Tags (RM 3.9(6/2)), attribute
'Tag (RM 3.9(16,18)), and function Ada.Tags.Generic_Dispatching_Constructor (RM
3.9(18.2/2)), which enable direct manipulation with tags.
The Language Reference Manual's section on 3.3 Objects and Named Numbers ˆ{http://www.
adaic.org/resources/add_content/standards/05rm/html/RM-3-3.html} states when
an object is created, and destroyed again. This subsection illustrates how objects are created.
Objects are created at run time and contain a value of a given type. An object
The LRM section starts, be created and initialized as part of elaborating a declaration, evaluating an alloc
aggregate, or function_call.
195
Object Orientation
For example, assume a typical hierarchy of object oriented types: a top-level type Person, a
Programmer type derived from Person, and possibly more kinds of persons. Each person
has a name; assume Person objects to have a Name component. Likewise, each Person has
a Gender component. The Programmer type inherits the components and the operations
of the Person type, so Programmer objects have a Name and a Gender component, too.
Programmer objects may have additional components specific to programmers.
Objects of a tagged type are created the same way as objects of any type. The second LRM
sentence says, for example, that an object will be created when you declare a variable or a
constant of a type. For the tagged type Person,
declare
P: Person;
begin
Text_IO. Put_Line( "The name is " & P. Name) ;
end;
Nothing special so far. Just like any ordinary variable declaration this O-O one is elaborated.
The result of elaboration is an object named P of type Person. However, P has only default
name and gender value components. These are likely not useful ones. One way of giving
initial values to the object's components is to assign an aggregate.
declare
P: Person := ( Name => "Scorsese", Gender => Male) ;
begin
Text_IO. Put_Line( "The name is " & P. Name) ;
end;
package Persons is
private
196
type Person is tagged
record
Name : String ( 1 .. 10) ;
Gender : Gender_Type;
end record;
end Persons;
Calling the Make function results in an object which can be used for initialization. Since the
Person type is private we can no longer refer to the Name component of P. But there is
a corresponding function Name declared with type Person making it a socalled primitive
operation. (The component and the function in this example are both named Name However,
we can choose a different name for either if we want.)
declare
P: Person := Make ( Name => "Orwell", Sex => Male) ;
begin
Text_IO. Put_Line( "The name is " & Name( P) ) ;
end;
Objects can be copied into another. The target object is first destroyed. Then the
component values of the source object are assigned to the corresponding components of the
target object. In the following example, the default initialized P gets a copy of one of the
objects created by the Make calls.
declare
P: Person;
begin
if 2001 > 1984 then
P := Make ( Name => "Kubrick", Sex => Male) ;
else
P := Make ( Name => "Orwell", Sex => Male) ;
end if;
So far there is no mention of the Programmer type derived from Person. There is no
polymorphism yet, and likewise initialization does not yet mention inheritance. Before
dealing with Programmer objects and their initialization a few words about class-wide types
are in order.
Remember what we said before about "Primitive Operations"2 . Primitive operations are:
• subprograms taking a parameter of the tagged type;
• functions returning an object of the tagged type;
• subprograms taking a parameter of an anonymous access type to the tagged type;
197
Object Orientation
• In Ada 2005 only, functions returning an anonymous access type to the tagged type;
Additionally, primitive operations must be declared before the type is frozen (the concept of
freezing will be explained later):
Examples:
package X is
type Object is tagged null record;
package X is
type Object is tagged null record;
The definition of primitive operations specifically excludes named access types and
class-wide types as well as operations not defined immediately in the same declarative
region. Counter-examples:
package X is
type Object is tagged null record;
type Object_Access is access Object;
type Object_Class_Access is access Object'Class;
package Inner is
procedure Not_Primitive_5 (This : in Object);
end Inner;
end X;
198
Advanced topic: Freezing rules
package X is
end X;
Intuitively: at the point where Derived is declared, the compiler starts a new table of
primitive operations for the derived type. This new table, initially, is equal to the table of
the primitive operations of the parent type, Object. Hence, Object must freeze.
• the declaration of a variable of the tagged type
Example:
package X is
end X;
3 http://en.wikibooks.org/wiki/%20ARM%2013.14
4 Chapter 22.1.6 on page 193
199
Object Orientation
Intuitively: after the declaration of V, it is possible to call any of the primitive operations of
the type on V. Therefore, the list of primitive operations must be known and complete, i.e.
frozen.
• The completion (not the declaration, if any) of a constant of the tagged type:
package X is
private
end X;
Overriding indicators
The new keyword overriding can be used to indicate whether an operation overrides an
inherited subprogram or not. Its use is optional because of upward-compatibility with Ada
95. For example:
package X is
type Object is tagged null record;
overriding
function Primitive return access Derived_Object;
end X;
200
This is a good programming practice because it avoids some nasty bugs like not overriding
an inherited subprogram because the programmer spelt the identifier incorrectly, or because
a new parameter is added later in the parent type.
It can also be used with abstract operations, with renamings, or when instantiating a
generic subprogram:
not overriding
procedure Primitive_X (This : in Object) is abstract;
overriding
function Primitive_Y return Object renames Some_Other_Subprogram;
not overriding
procedure Primitive_Z (This : out Object)
is new Generic_Procedure (Element => Integer);
Object.Method notation
package X is
type Object is tagged null record;
with X;
procedure Main is
Obj : X.Object;
begin
Obj.Primitive (That => True); --Ada 2005 object.method notation
end Main;
This notation is only available for primitive operations where the controlling parameter is
the first parameter.
A tagged type can also be abstract (and thus can have abstract operations):
package X is
end X;
201
Object Orientation
An abstract operation cannot have any body, so derived types are forced to override it
(unless those derived types are also abstract). See next section about interfaces for more
information about this.
The difference with a non-abstract tagged type is that you cannot declare any variable of
this type. However, you can declare an access to it, and use it as a parameter of a class-wide
operation.
package Printable is
end Printable;
with Person;
package Programmer is
overriding
procedure Class_Member_1 (This : in Object);
not overriding
procedure New_Class_Member (This : Object; That : String);
end Programmer;
As usual, all inherited abstract operations must be overridden although null subprograms
ones need not.
202
Such a type may implement a list of interfaces (called the progenitors), but can have only
one parent. The parent may be a concrete type or also an interface.
type Derived is new Parent and Progenitor_1 and Progenitor_2 ... with ...;
Ada supports multiple inheritance of interfaces (see above), but only single inheritance of
implementation. This means that a tagged type can implement multiple interfaces but can
only extend a single ancestor tagged type.
This can be problematic if you want to add behavior to a type that already extends another
type; for example, suppose you have
and you want to make Derived controlled, i.e. add the behavior that Derived controls its
initialization, assignment and finalization. Alas you cannot write:
since Ada.Finalization for historical reasons does not define interfaces Controlled and
Limited_Controlled, but abstract types.
If your base type is not limited, there is no good solution for this; you have to go back to
the root of the class and make it controlled. (The reason will become obvious presently.)
For limited types however, another solutions is the use of a mix-in:
This special kind of mix-in is an object with an access discriminant that references its
enclosing object (also known as Rosen trick). In the declaration of the Derived type, we
initialize this discriminant with a special syntax: Derived'Access really refers to an a
access value to the current instance of type Derived. Thus the access discriminant allows
the mix-in to see its enclosing object and all its components; therefore it can initialize and
203
Object Orientation
X := Y;
In an assignment statement, Adjust is called only after Finalize of the target X and
so cannot provide the new value of the discriminant. Thus X.Mixin_In.Enclosing will
inevitably reference Y.
Now let's further extend our hierarchy:
Oops, this does not work because there are no corresponding procedures for Derived, yet -
so let's quickly add them.
not overriding procedure Initialize (This: in out Derived); --sic, they are new
not overriding procedure Finalize (This: in out Derived);
204
We have of course to write not overriding for the procedures on Derived because there is
indeed nothing they could override. The bodies are
To our dismay, we have to learn that Initialize/Finalize for objects of type Further
will not be called, instead those for the parent Derived. Why?
declare
X: Further; -- Initialize (Derived (X)) is called here
begin
null;
end; -- Finalize (Derived (X)) is called here
The reason is that the mix-in defines the local object Enclosing to be of type Derived
in the renames-statement above. To cure this, we have necessarily to use the dreaded
redispatch (shown in different but equivalent notations):
declare
X: Further; -- Initialize (X) is called here
begin
null;
end; -- Finalize (X) is called here
Then we automatically get redispatch and can omit the type conversions on Enclosing.
205
Object Orientation
Class names
Both the class package and the class record need a name. In theory they may have the
same name, but in practice this leads to nasty (because of unintutive error messages) name
clashes when you use the use clause. So over time three de facto naming standards have
been commonly used.
22.2.1 Classes/Class
The package is named by a plural noun and the record is named by the corresponding
singular form.
package Persons is
end Persons;
22.2.2 Class/Object
The package is named after the class, the record is just named Object.
package Person is
end Person;
5 http://en.wikipedia.org/wiki/Unified%20Modeling%20Language
6 http://en.wikipedia.org/wiki/Interface%20description%20language
206
22.2.3 Class/Class_Type
The package is named after the class, the record is postfixed with _Type.
package Person is
end Person;
class C {
virtual void v();
void w();
static void u();
};
package P is
type C is tagged null record;
procedure V (This : C); --primitive operation, will be inherited upon derivation
procedure W (This : C'Class); --not primitive, will not be inherited upon derivation
procedure U;
end P;
In C++, member functions implicitly take a parameter this which is of type C*. In Ada,
all parameters are explicit. As a consequence, the fact that u() does not take a parameter
is implicit in C++ but explicit in Ada.
In C++, this is a pointer. In Ada, the explicit This parameter does not have to be a
pointer; all parameters of a tagged type are implicitly passed by reference anyway.
207
Object Orientation
For example:
C object;
object.v();
object.w();
both dispatch statically. In particular, the static dispatch for v() may be confusing; this is
because object is neither a pointer nor a reference. Ada behaves exactly the same in this
respect, except that Ada calls this static binding rather than dispatching:
declare
Object : P.C;
begin
Object.V; --statically bound
Object.W; --statically bound
end;
In C++, a function call dispatches dynamically if the two following conditions are met
simultaneously:
• the target of the call is a pointer or a reference
• the member function is virtual.
For example:
C* object;
object->v(); // dynamic dispatch
object->w(); // static, non-virtual member function
object->u(); // illegal: static member function
C::u(); // static dispatch
declare
Object : P.C'Class := ...;
begin
P.V (Object); --dispatching
P.W (Object); --statically bound: not a primitive operation
P.U; --statically bound
end;
As can be seen there is no need for access types or pointers to do dispatching in Ada. In
Ada, tagged types are always passed by-reference to subprograms without the need for explicit
access values.
208
Also note that in C++, the class serves as:
• the unit of encapsulation (Ada uses packages and visibility for this)
• the type, like in Ada.
As a consequence, you call C::u() in C++ because u() is encapsulated in C, but P.U in Ada
since U is encapsulated in the package P, not the type C.
The most confusing part for C++ programmers is the concept of a "class-wide type". To
help you understand:
• pointers and references in C++ are really, implicitly, class-wide;
• object types in C++ are really specific;
• C++ provides no way to declare the equivalent of:
type C_Specific_Access is access C;
which, in Ada, are two different, incompatible types, possibly allocating their memory from
different storage pools!
• In Ada, you do not need access values for dynamic dispatching.
• In Ada, you use access values for dynamic memory management (only) and class-wide
types for dynamic dispatching (only).
• In C++, you use pointers and references both for dynamic memory management and for
dynamic dispatching.
• In Ada, class-wide types are explicit (with 'Class).
• In C++, class-wide types are implicit (with * or &).
22.3.4 Constructors
class C {
C(/* optional parameters */); // constructor
};
209
Object Orientation
subprograms do not have to have a special name and there can be as many constructors as
necessary; each function can take parameters as appropriate.
package P is
type T is tagged private;
function Make return T; -- constructor
function To_T (From: Integer) return T; -- another constructor
-- procedure Make (This: out T); -- not a constructor
private
...
end P;
If an Ada constructor function is also a primitive operation (as in the example above), it
becomes abstract upon derivation and has to be overridden if the derived type is not itself
abstract. If you do not want this, declare such functions in a nested scope.
In C++, one idiom is the copy constructor and its cousin the assignment operator:
class C {
C(const C& that); // copies "that" into "this"
C& operator= (const C& right); // assigns "right" to "this",
which is "left"
};
Ada provides a similar functionality by means of controlled types. A controlled type is one
that extends the predefined type Ada.Finalization.Controlled:
with Ada.Finalization;
package P is
type T is new Ada.Finalization.Controlled with private;
function Make return T; -- constructor
private
type T is ... end record;
overriding procedure Initialize (This: in out T);
overriding procedure Adjust (This: in out T); -- copy contructor
end P;
Note that Initialize is not a constructor; it resembles the C++ constructor in some way, but
is also very different. Suppose you have a type T1 derived from T with an appropriate
overriding of Initialize. A real constructor (like the C++ one) would automatically first
construct the parent components (T), then the child components. In Ada, this is not
automatic. In order to mimic this in Ada, we have to write:
210
Initialize (T (This)); -- Don't forget this part!
... -- handle the new components here
end Initialize;
The compiler inserts a call to Initialize after each object of type T is allocated when no
initial value is given. It also inserts a call to Adjust after each assignment to the object.
Thus, the declarations:
A: T;
B: T := X;
will:
• allocate memory for A
• call Initialize (A)
• allocate memory for B
• copy the contents of X to B
• call Adjust (B)
Initialize (B) will not be called because of the explicit initialization.
So, the equivalent of a copy constructor is an overriding of Adjust.
If you would like to provide this functionality to a type that extends another, non-controlled
type, see "Multiple Inheritance"7 .
22.3.5 Destructors
In C++, a destructor is a member function with only the implicit this parameter:
class C {
virtual ˜C(); // destructor
}
While a constructor cannot be virtual, a destructor must be virtual. Unfortunately, the rules
of the C++ language do not enforce this, so it is quite easy for a programmer to wreak
havoc in their programs by simply forgetting the keyword virtual.
In Ada, the equivalent functionality is again provided by controlled types, by overriding the
procedure Finalize:
with Ada.Finalization;
package P is
type T is new Ada.Finalization.Controlled with private;
function Make return T; -- constructor
private
type T is ... end record;
211
Object Orientation
In C++, the unit of encapsulation is the class; in Ada, the unit of encapsulation is the
package. This has consequences on how an Ada programmer places the various components
of an object type.
class C {
public:
int a;
void public_proc();
protected:
int b;
int protected_func();
private:
bool c;
void private_proc();
};
A way to mimic this C++ class in Ada is to define a hierarchy of types, where the base type
is the public part, which must be abstract so that no stand-alone objects of this base type
can be defined. It looks like so:
package CPP is
212
type Complete_Type is new Public_Part with record
B: Integer;
P: Private_Component; -- must be controlled to avoid storage
leaks
end record;
end CPP;
The private part is defined as a stub only, its completion is hidden in the body. In order
to make it a component of the complete type, we have to use a pointer since the size of
the component is still unknown (the size of a pointer is known to the compiler). With
pointers, unfortunately, we incur the danger of memory leaks, so we have to make the private
component controlled.
For a little test, this is the body, where the subprogram bodies are provided with identifying
prints:
with Ada.Unchecked_Deallocation;
with Ada.Text_IO;
213
Object Orientation
begin
Ada.Text_IO.Put_Line ("Protected_Proc" & Integer'Image (This.A)
& Integer'Image (This.B));
Private_Proc (X);
end Protected_Proc;
end CPP;
We see that, due to the construction, the private procedure is not a primitive operation.
Let's define a child class so that the protected operation can be reached:
package CPP.Child is
end CPP.Child;
A child can look inside the private part of the parent and thus can see the protected procedure:
with Ada.Text_IO;
end CPP.Child;
with CPP.Child;
use CPP.Child, CPP;
procedure Test_CPP is
X, Y: Complete_Type;
begin
X.A := +1;
Y.A := -1;
X := Y;
end Test_CPP;
214
This is the commented output of the test program:
You see that a direct translation of the C++ behaviour into Ada is difficult, if feasible at
all. Methinks, the primitive Ada subprograms corresponds more to virtual C++ methods
(in the example, they are not). Each language has its own idiosyncrasies which have to be
taken into account, so that attempts to directly translate code from one into the other may
not be the best approach.
In C++, a friend function or class can see all members of the class it is a friend of. Friends
break encapsulation and are therefore to be discouraged. In Ada, since packages and not
classes are the unit of encapsulation, a "friend" subprogram is simply one that is declared in
the same package as the tagged type.
In C++, stream input and output are the particular case where friends are usually necessary:
#include <iostream>
class C {
public:
C();
friend ostream& operator<<(ostream& output, C& arg);
private:
int a, b;
bool c;
};
215
Object Orientation
#include <iostream>
int main() {
C object;
cout << object;
return 0;
};
Ada does not need this construct because it defines stream input and output operations by
default:
package P is
pragma Elaborate_Body; -- explained below
type C is tagged private;
private
type C is tagged record
A, B : Integer;
C : Boolean;
end record;
end P;
with Ada.Text_IO.Text_Streams;
with P;
procedure Main is
Object : P.C;
begin
P.C'Output (Stream => Ada.Text_IO.Text_Streams.Stream
(Ada.Text_IO.Default_Output),
Item => Object);
end Main;
By default, the Output attribute sends the tag of the object to the stream then calls the
more basic Write attribute, which sends the components to the stream in the same order as
the declaration, i.e. A, B then C. It is possible to override the default implementation of the
Input, Output, Read and Write attributes like this:
with Ada.Streams;
package body P is
procedure My_Write (Stream : not null access
Ada.Streams.Root_Stream_Type'Class;
Item : in C) is
begin
-- The default is to write A then B then C; here we change the
ordering.
Boolean'Write (Stream, Item.C);
Integer'Write (Stream, Item.B);
Integer'Write (Stream, Item.A);
end My_Write;
In the above example, P.C'output calls P.C'Write which is overridden in the body of the
package. Since the specification of package P does not define any subprograms, it does not
normally need a body, so a package body is forbidden. The pragma Elaborate_Body tells
the compiler that this package does have a body that is needed for other reasons.
216
Note that the stream IO attributes are not primitive operations of the tagged type; this is
also the case in C++ where the friend operators are not, in fact, member functions of the
type.
22.3.8 Terminology
Ada C++
Package class (as a unit of encapsulation)
Tagged type class (of objects) (as a type) (not pointer or
reference, which are class-wide)
Primitive operation virtual member function
Tag pointer to the virtual table
Class (of types) -
Class-wide type -
Class-wide operation static member function
Access value to a specific tagged -
type
Access value to a class-wide type Pointer or reference to a class
22.4.1 Wikibook
• Ada Programming8
• Ada Programming/Types/record9
• record10
• interface11
• tagged12
22.4.2 Wikipedia
• Object-oriented programming13
8 http://en.wikibooks.org/wiki/Ada%20Programming
9 Chapter 12 on page 91
10 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Frecord
11 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Finterface
12 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Ftagged
13 http://en.wikipedia.org/wiki/Object-oriented%20programming
217
Object Orientation
Ada 95
Ada 2005
14 http://es.wikibooks.org/wiki/Programaci%F3n%20en%20Ada%2FTipos%20etiquetados
218
23 New in Ada 2005
This is an overview of the major features that are available in Ada 2005, the version of
the Ada standard that was accepted by ISO in January 2007 (to differentiate it from its
predecessors Ada 831 and Ada 952 , the informal name Ada 2005 is generally agreed on). For
the rationale and a more detailed (and very technical) description, see the Amendment3
to the Ada Reference Manual following the links to the last version of every Ada Issue
document (AI).
Although the standard is now published, not all compilers will be able to handle it. Many
of these additions are already implemented by the following Free Software4 compilers:
• GNAT GPL Edition5
• GCC 4.16
• GNAT Pro 6.0.27 (the AdaCore supported version) is a complete implementation.
After downloading and installing any of them, remember to use the -gnat05 switch when
compiling Ada 2005 code. Note that Ada 2005 is the default mode in GNAT GPL 2007
Edition.
Not only does Ada 2005 now support a new 32-bit character type — called Wide_Wide_-
Character — but the source code itself may be of this extended character set as well. Thus
Russians and Indians, for example, will be able to use their native language in identifiers
and comments. And mathematicians will rejoice: The whole Greek and fractur character
sets are available for identifiers. For example, Ada.Numerics8 will be extended with a new
constant:
1 http://en.wikibooks.org/wiki/Ada%20Programming%2FAda%2083
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FAda%2095
3 http://www.ada-auth.org/AI-XREF.HTML#Amend_Doc
4 http://en.wikipedia.org/wiki/Free%20Software
5 http://libre.adacore.com/
6 http://gcc.gnu.org/
7 http://www.adacore.com/home/gnatpro/
8 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics
219
New in Ada 2005
π : constant := Pi;
This is not a new idea — GNAT9 always had the -gnatic compiler option to specify the
character set http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Character-Set-Control.
html. But now this idea has become standard, so all Ada compilers will need to support
Unicode 4.010 for identifiers — as the new standard requires.
See also:
• AI95-00285-01 Support for 16-bit and 32-bit characters ˆ{http://www.ada-auth.org/
cgi-bin/cvsweb.cgi/AIs/AI-00285.TXT}
• AI95-00388-01 Add Greek pi to Ada.Numerics ˆ{http://www.ada-auth.org/cgi-bin/
cvsweb.cgi/AIs/AI-00388.TXT}
23.1.2 Interfaces
Interfaces allow for a limited form of multiple inheritance similar to Java and C#.
You find a full description here: Ada Programming/OO11 .
See also:
• AI95-00251-01 Abstract Interfaces to provide multiple inheritance ˆ{http://www.
ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00251.TXT}
• AI95-00345-01 Protected and task interfaces ˆ{http://www.ada-auth.org/cgi-bin/
cvsweb.cgi/AIs/AI-00345.TXT}
23.1.3 Union
In addition to Ada's safe variant record an unchecked C style union is now available.
You can find a full description here: Ada Programming/Types/record#Union12 .
See also:
• AI95-00216-01 Unchecked unions -- variant records with no run-time discriminant ˆ{http:
//www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00216.TXT}
• Annex B.3.3 Pragma Unchecked_Union ˆ{http://www.adaic.org/resources/add_
content/standards/05rm/html/RM-B-3-3.html}
9 http://en.wikipedia.org/wiki/GNAT
10 http://en.wikipedia.org/wiki/Unicode
11 Chapter 22.4.2 on page 217
12 Chapter 12.6 on page 95
220
23.1.4 With
The with statement got a massive upgrade. First there is the new limited with13 which
allows two packages to with each other. Then there is private with14 to make a package only
visible inside the private part of the specification.
See also:
• AI95-00217-01 Limited With Clauses ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.
cgi/AIs/AI-00217.TXT}
• AI95-00262-01 Access to private units in the private part ˆ{http://www.ada-auth.org/
cgi-bin/cvsweb.cgi/AIs/AI-00262.TXT}
An access type definition can specify that the access type can never be null.
See Ada Programming/Types/access#Not null access15 .
See also: AI95-00231-01 Access-to-constant parameters and null-excluding access subtypes
ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00231.TXT}
Anonymous access
The possible uses of anonymous access types are extended. They are allowed virtually in
every type or object definition, including access to subprogram parameters. Anonymous
access types may point to constant objects as well. Also, they could be declared to be not
null.
With the addition of the following operations in package Standard , it is possible to test the
equality of anonymous access types.
221
New in Ada 2005
23.2.1 Containers
A major addition to the language library is the generic packages for containers. If you are
familiar with the C++ STL, you will likely feel very much at home using Ada . One thing,
though: Ada is a block structured language. Many ideas of how to use the STL employ
this feature of the language. For example, local subprograms can be supplied to iteration
schemes.
The original Ada Issue text AI95-00302-01 Container library ˆ{http://www.ada-auth.org/
cgi-bin/cvsweb.cgi/AIs/AI-00302.TXT} has now been transformed into A.18 Contain-
ers ˆ{http://www.adaic.org/resources/add_content/standards/05rm/html/RM-A-18.
html} .
If you know how to write Ada programs, and have a need for vectors, lists, sets, or maps
(tables), please have a look at the AI95-00302-01 AI Text ˆ{http://www.ada-auth.org/
cgi-bin/cvsweb.cgi/AIs/AI-00302.TXT} mentioned above. There is an !example section
in the text explaining the use of the containers in some detail. Matthew Heaney provides
a number of demonstration programs with his reference implementation of AI-302 (Ada )
which you can find at tigris17 .
In Ada Programming/Containers18 you will find a demo using containers.
Historical side note: The C++ STL draws upon the work of David R. Musser and
Alexander A. Stepanov. For some of their studies of generic programming, they had been
using Ada 83. The Stepanov Papers Collection19 has a few publications available.
See also:
• AI95-00248-01 Directory Operations ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.
cgi/AIs/AI-00248.TXT}
• AI95-00370-01 Environment variables ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.
cgi/AIs/AI-00370.TXT}
17 http://charles.tigris.org
18 Chapter 24 on page 231
19 http://www.stepanovpapers.com/
222
23.2.3 Numerics
Besides the new constant of package Ada.Numerics (see Character Set20 above), the most
important addition are the packages to operate with vectors and matrices.
See also:
• AI95-00388-01 Add Greek pi (π) to Ada.Numerics ˆ{http://www.ada-auth.org/
cgi-bin/cvsweb.cgi/AIs/AI-00388.TXT}
• AI95-00296-01 Vector and matrix operations ˆ{http://www.ada-auth.org/cgi-bin/
cvsweb.cgi/AIs/AI-00296.TXT}
(Related note on Ada programming tools: AI-388 contains an interesting assessment of how
compiler writers are bound to perpetuate the lack of handling of international characters in
programming support tools for now. As an author of Ada programs, be aware that your
tools provider or Ada consultant could recommend that the program text be 7bit ASCII
only.)
See also:
• AI95-00297-01 Timing events ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/
AI-00297.TXT}
• AI95-00307-01 Execution-Time Clocks ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.
cgi/AIs/AI-00307.TXT}
• AI95-00354-01 Group execution-time budgets ˆ{http://www.ada-auth.org/cgi-bin/
cvsweb.cgi/AIs/AI-00354.TXT}
• AI95-00266-01 Task termination procedure ˆ{http://www.ada-auth.org/cgi-bin/
cvsweb.cgi/AIs/AI-00266.TXT}
• AI95-00386-01 Further functions returning Time_Span values ˆ{http://www.ada-auth.
org/cgi-bin/cvsweb.cgi/AIs/AI-00386.TXT}
See also:
• AI95-00249-01 Ravenscar profile for high-integrity systems ˆ{http://www.ada-auth.
org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT}
• AI95-00305-01 New pragma and additional restriction identifiers for real-time systems
ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
• AI95-00347-01 Title of Annex H ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/
AIs/AI-00347.TXT}
223
New in Ada 2005
See also:
• AI95-00355-01 Priority Specific Dispatching including Round Robin ˆ{http://www.
ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00355.TXT}
• AI95-00357-01 Support for Deadlines and Earliest Deadline First Scheduling ˆ{http:
//www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00357.TXT}
• AI95-00298-01 Non-Preemptive Dispatching ˆ{http://www.ada-auth.org/cgi-bin/
cvsweb.cgi/AIs/AI-00298.TXT}
Added 11 pragmas:
• pragma
• pragma
• pragma
• pragma
• pragma
• pragma
• pragma
• pragma
• pragma
• pragma
• pragma
224
23.4.3 New attributes
Added 7 attributes:
• Machine_Rounding
• Mod
• Priority
• Stream_Size
• Wide_Wide_Image
• Wide_Wide_Value
• Wide_Wide_Width
• Assertions:
• Ada.Assertions
• Container library:
• Ada.Containers
• Ada.Containers.Vectors
• Ada.Containers.Doubly_Linked_Lists
• Ada.Containers.Generic_Array_Sort (generic procedure)
• Ada.Containers.Generic_Constrained_Array_Sort (generic procedure)
• Ada.Containers.Hashed_Maps
• Ada.Containers.Ordered_Maps
• Ada.Containers.Hashed_Sets
• Ada.Containers.Ordered_Sets
• Ada.Containers.Indefinite_Vectors
• Ada.Containers.Indefinite_Doubly_Linked_Lists
• Ada.Containers.Indefinite_Hashed_Maps
• Ada.Containers.Indefinite_Ordered_Maps
• Ada.Containers.Indefinite_Hashed_Sets
• Ada.Containers.Indefinite_Ordered_Sets
• Vector and matrix manipulation:
• Ada.Numerics.Real_Arrays
• Ada.Numerics.Complex_Arrays
• Ada.Numerics.Generic_Real_Arrays
• Ada.Numerics.Generic_Complex_Arrays
• General OS facilities:
• Ada.Directories
• Ada.Directories.Information
• Ada.Environment_Variables
• String hashing:
• Ada.Strings.Hash (generic function)
• Ada.Strings.Fixed.Hash (generic function)
• Ada.Strings.Bounded.Hash (generic function)
225
New in Ada 2005
226
• Task termination procedures:
• Ada.Task_Termination
23.5.1 Wikibook
21 http://en.wikibooks.org/wiki/Ada%20Programming%2FAda%2083
22 http://en.wikibooks.org/wiki/Ada%20Programming%2FAda%2095
23 http://en.wikibooks.org/wiki/Ada%20Programming%2FAda%202012
24 Chapter 22 on page 187
25 Chapter 13 on page 99
26 Chapter 35 on page 293
27 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Fand
28 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Finterface
29 Chapter 38 on page 305
30 Chapter 39 on page 317
31 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FRestrictions
32 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers
33 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Directories
34 http://en.wikibooks.org/wiki/%3ACategory%3AAda%20Programming%2FAda%202005%20feature
227
New in Ada 2005
External links
23.6.2 Rationale
• Instructions to the Ada Rapporteur Group from SC22/WG9 for Preparation of the
Amendment to ISO/IEC 865242 (10 October 2002), and a presentation of this document43
at SIGAda 2002
http://www.sigada.org/conf/sigada2004/SIGAda2004-CDROM/SIGAda2004-Proceedings/
35
Ada2005Panel.pdf
36 http://www.adacore.com/wp-content/files/attachments/Ada_2005_and_GNAT.pdf
37 http://sigada.org/ada_letters/sept2003/Invitation_to_Ada_2005.pdf
38 http://www.cs.kuleuven.ac.be/~dirk/ada-belgium/events/04/040616-aec-ada2005.pdf
39 http://www.adaic.com/standards/05rat/html/Rat-TTL.html
40 http://en.wikipedia.org/wiki/John%20Barnes%20%28computer%20scientist%29
41 http://www.adaic.com/standards/05rat/Rationale05.pdf
42 http://www.open-std.org/jtc1/sc22/WG9/n412.pdf
43 http://std.dkuug.dk/JTC1/sc22/wg9/n423.pdf
44 http://www.adaic.com/standards/05rm/html/RM-TTL.html
228
• Annotated Ada Reference Manual, ISO/IEC 8652:1995(E) with COR.1:2001 and
AMD.1:200745 (colored diffs)
• List of Ada Amendment drafts46
• Amendment 200Y47
• AI95-00387-01 Introduction to Amendment ˆ{http://www.ada-auth.org/cgi-bin/
cvsweb.cgi/AIs/AI-00387.TXT}
• AI95-00284-01 New reserved words ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.
cgi/AIs/AI-00284.TXT}
• AI95-00252-01 Object.Operation notation ˆ{http://www.ada-auth.org/cgi-bin/
cvsweb.cgi/AIs/AI-00252.TXT}
• AI95-00218-01 Accidental overloading when overriding ˆ{http://www.ada-auth.org/
cgi-bin/cvsweb.cgi/AIs/AI-00218.TXT}
• AI95-00348-01 Null procedures ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/
AIs/AI-00348.TXT}
• AI95-00287-01 Limited aggregates allowed ˆ{http://www.ada-auth.org/cgi-bin/
cvsweb.cgi/AIs/AI-00287.TXT}
• AI95-00326-01 Incomplete types ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.
cgi/AIs/AI-00326.TXT}
• AI95-00317-01 Partial parameter lists for formal packages ˆ{http://www.ada-auth.
org/cgi-bin/cvsweb.cgi/AIs/AI-00317.TXT}
• AI95-00376-01 Interfaces.C works for C++ as well ˆ{http://www.ada-auth.org/
cgi-bin/cvsweb.cgi/AIs/AI-00376.TXT}
• AI95-00368-01 Restrictions for obsolescent features ˆ{http://www.ada-auth.org/
cgi-bin/cvsweb.cgi/AIs/AI-00368.TXT}
• AI95-00381-01 New Restrictions identifier No_Dependence ˆ{http://www.ada-auth.
org/cgi-bin/cvsweb.cgi/AIs/AI-00381.TXT}
• AI95-00224-01 pragma Unsuppress ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.
cgi/AIs/AI-00224.TXT}
• AI95-00161-01 Default-initialized objects ˆ{http://www.ada-auth.org/cgi-bin/
cvsweb.cgi/AIs/AI-00161.TXT}
• AI95-00361-01 Raise with message ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.
cgi/AIs/AI-00361.TXT}
• AI95-00286-01 Assert pragma ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/
AIs/AI-00286.TXT}
• AI95-00328-01 Preinstantiations of Complex_IO ˆ{http://www.ada-auth.org/
cgi-bin/cvsweb.cgi/AIs/AI-00328.TXT}
• AI95-00301-01 Operations on language-defined string types ˆ{http://www.ada-auth.
org/cgi-bin/cvsweb.cgi/AIs/AI-00301.TXT}
• AI95-00340-01 Mod attribute ˆ{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/
AIs/AI-00340.TXT}
45 http://www.adaic.com/standards/05aarm/html/AA-TTL.html
46 http://www.ada-auth.org/amendment.html
47 http://www.ada-auth.org/AI-XREF.HTML#Amend_Doc
229
New in Ada 2005
230
24 Containers
What follows is a simple demo of some of the container types. It does not cover everything,
but should get you started.
This language feature is only available in Ada 2005
The program below prints greetings to the world in a number of human languages. The
greetings are stored in a table, or hashed map. The map associates every greeting (a value)
with a language code (a key). That is, you can use language codes as keys to find greeting
values in the table.
The elements in the map are constant strings of international characters, or really, pointers
to such constant strings. A package Regional is used to set up both the language IDs and
an instance of Ada .
File: regional.ads
package Regional is
end Regional;
231
Containers
File: hello_world_extended.ads
procedure Hello_World_Extended is
greetings: Phrases.Map;
--the dictionary of greetings
begin -- Hello_World_Extended
Phrases.Insert(greetings,
Key => EN,
New_Item => new Wide_String'("Hello, World!"));
--or, shorter,
greetings.Insert(DE, new Wide_String'("Hallo, Welt!"));
greetings.Insert(NL, new Wide_String'("Hallo, Wereld!"));
greetings.Insert(ES, new Wide_String'("¡Hola mundo!"));
greetings.Insert(FR, new Wide_String'("Bonjour, Monde!"));
greetings.Insert(EL, new Wide_String'("Γειάσου κόσμος"));
--Καλημέρα κόσμε?
declare
use Phrases;
end Hello_World_Extended;
Phrases.Insert(greetings,
Key => EN,
New_Item => new Wide_String'("Hello, World!"));
The next insertions use so called distinguished receiver notation which you can use in
Ada 2005. (It's O-O parlance. While the Insert call involves all of: a Container object
(greetings), a Key object (EN), and a New_Item object (new Wide_String'("Hello,
World!")), the Container object is distinguished from the others in that the Insert
call provides it (and only it) with the other objects. In this case the Container object
will be modified by the call, using arguments named Key and New_Item for the modification.)
232
greetings.Insert(ES, new Wide_String'("¡Hola mundo!"));
After the table is set up, the program goes on to print all the greetings contained in the
table. It does so employing a cursor that runs along the elements in the table in some order.
The typical scheme is to obtain a cursor, here using First, and then to iterate the following
calls:
1. Has_Element, for checking whether the cursor is at an element
2. Element, to get the element and
3. Next, to move the cursor to another element
When there is no more element left, the cursor will have the special value No_Element.
Actually, this is an iteration scheme that can be used with all containers in child packages
of Ada .
The next program shows how to pick a value from the map, given a key. Actually, you will
provide the key. The program is like the previous one, except that it doesn't just print all
the elements in the map, but picks one based on a Language_ID value that it reads from
standard input.
File: hello_world_pick.adb
procedure Hello_World_Pick is
declare
use Phrases;
end Hello_World_Pick;
This time the Element function consumes a Key (lang) not a Cursor. Actually, it consumes
two values, the other value being greetings, in distinguished receiver notation.
233
Containers
Let's take bean counting literally. Red beans, green beans, and white beans. (Yes, white
beans really do exist.) Your job will be to collect a number of beans, weigh them, and
then determine the average weight of red, green, and white beans, respectively. Here is one
approach.
Again, we need a package, this time for storing vegetable related information. Introducing
the Beans package (the Grams type doesn't belong in a vegetable package, but it's there to
keep things simple):
File: 1/beans.ads
with Ada ;
package Beans is
type Bean_Color is ( R, G, W) ;
--red, green, and white beans
type Bean is
--info about a single bean
record
kind: Bean_Color;
weight: Grams;
end record;
end Beans;
The Vectors instance offers a data structure similar to an array that can change its size at run
time. It is called Vector. Each bean that is read will be appended to a Bean_Vecs.Vector
object.
The following program first calls read_input to fill a buffer with beans. Next, it calls a
function that computes the average weight of beans having the same color. This function:
function average_weight
( buffer: Bean_Vecs. Vector; desired_color: Bean_Color) return Grams;
--scan ‘buffer‘ for all beans that have ‘desired_color‘. Compute the
--mean of their ‘.weight‘ components
234
Then the average value is printed for beans of each color and the program stops.
File: 1/bean_counting.adb
with Beans;
with average_weight;
with Ada ;
procedure bean_counting is
use Beans, Ada;
begin --bean_counting
read_input( buffer) ;
end bean_counting;
All container operations take place in function average_weight. To find the mean weight
of beans of the same color, the function is looking at all beans in order. If a bean has the
right color, average_weight adds its weight to the total weight, and increases the number
of beans counted by 1.
The computation visits all beans. The iteration that is necessary for going from one bean to
the next and then performing the above steps is best left to the Iterate procedure which is
part of all container packages. To do so, wrap the above steps inside some procedure and
pass this procedure to Iterate. The effect is that Iterate calls your procedure for each
element in the vector, passing a cursor value to your procedure, one for each element.
Having the container machinery do the iteration can also be faster than moving and
checking the cursor yourself, as was done in the Hello_World_Extended example.
File: average_weight.adb
function average_weight
235
Containers
number: Natural := 0;
--number of beans in ‘buffer‘ having ‘desired_color‘
begin --average_weight
end average_weight;
...
type Bean_Pots is array( Bean_Color) of Bean_Vecs. Vector;
...
Note how this plain array associates colors with Vectors. The procedure for getting the
beans into the right bowls uses the bean color as array index for finding the right bowl (vector).
File: 2/gather_into_pots.adb
236
--the bean to the selected bowl
begin
Append( pots( Element( c) . kind) , Element( c) ) ;
end put_into_right_pot;
begin --gather_into_pots
Iterate( buffer, put_into_right_pot' Access) ;
end gather_into_pots;
File: 2/bean_counting.adb
with Beans;
with average_weight;
with gather_into_pots;
with Ada. Wide_Text_IO;
procedure bean_counting is
use Beans, Ada;
begin --bean_counting
read_input( buffer) ;
end bean_counting;
As a side effect of having chosen one vector per color, we can determine the number of beans
in each vector by calling the Length function. But average_weight, too, computes the
number of elements in the vector. Hence, a summing function might replace average_weight
here.
The following program first calls read_input to fill a buffer with beans. Then, information
about these beans is stored in a table, mapping bean properties to numbers of occurrence.
237
Containers
The processing that starts at Iterate uses chained procedure calls typical of the Ada
iteration mechanism.
The Beans package in this example instantiates another generic library unit, Ada . Where
the Ada require a hashing function, Ada require a comparison function. We provide one,
"<", which sorts beans first by color, then by weight. It will automatically be associated
with the corresponding generic formal function, as its name, "<", matches that of the
generic formal function, "<".
...
function "<"( a, b: Bean) return Boolean;
--order beans, first by color, then by weight
package Bean_Statistics
--instances will map beans of a particular color and weight to the
--number of times they have been inserted.
is new Ada. Containers. Ordered_Maps
( Element_Type => Natural,
Key_Type => Bean) ;
...
Where the previous examples have withed subprograms, this variation on bean_counting
packs them all as local subprograms.
File: 3/bean_counting.adb
with Beans;
with Ada. Wide_Text_IO;
procedure bean_counting is
use Beans, Ada;
c : Bean_Statistics. Cursor;
inserted: Boolean;
begin
stats_cw. Insert( specimen, 0, c, inserted) ;
Bean_Statistics. Update_Element( c, one_more' Access) ;
238
end add_bean_info;
begin --bean_counting
read_input( buffer) ;
--next, for all beans in the vector ‘buffer‘ just filled, store
--information about each bean in the ‘stats_cw‘ table.
declare
use Bean_Vecs;
declare
use Bean_Statistics;
q_sum: Grams;
q_count: Natural;
--precondition
pragma assert( not Is_Empty( stats_cw) , "container is empty") ;
begin
239
Containers
end bean_counting;
Like in the greetings example, you can pick values from the table. This time the values tell
the number of occurrences of beans with certain properties. The stats_cw table is ordered
by key, that is by bean properties. Given particular properties, you can use the Floor
and Ceiling functions to approximate the bean in the table that most closely matches the
desired properties.
It is now easy to print a histogram showing the frequency with which each kind of bean has
occurred. If N is the number of beans of a kind, then print N characters on a line, or draw
a graphical bar of length N, etc. A histogram showing the number of beans per color can
be drawn after computing the sum of beans of this color, using groups like in the previous
example. You can delete beans of a color from the table using the same technique.
Finally, think of marshalling the beans in order starting at the least frequently occurring
kind. That is, construct a vector appending first beans that have occurred just once, followed
by beans that have occurred twice, if any, and so on. Starting from the table is possible, but
be sure to have a look at the sorting functions of Ada .
24.1.1 Wikibook
• Ada Programming1
• Ada Programming/Libraries/Ada.Containers2
1 http://en.wikibooks.org/wiki/Ada%20Programming
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers
240
24.1.2 Ada 2005 Reference Manual
241
25 Interfacing
25.1 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.
The language standard defines the interfaces for C1 , Cobol2 and Fortran3 . Of course any
implementation might define further interfaces — GNAT4 for example defines an interface
to C++5 .
Interfacing with other languages is actually provided by pragma Export6 , Import7 and
Convention8 .
Embedded programmers usually have to write device drivers. Ada provides extensive
support for interfacing with hardware, like using representation clauses9 to specify the exact
representation of types used by the hardware, or standard interrupt handling for writing
Interrupt service routine10 s.
1 http://en.wikibooks.org/wiki/C%20Programming
2 http://en.wikibooks.org/wiki/COBOL
3 http://en.wikibooks.org/wiki/Programming%3AFortran
4 http://en.wikibooks.org/wiki/Ada%20Programming%2FGNAT
5 http://en.wikibooks.org/wiki/C%2B%2B%20Programming
6 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FExport
7 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FImport
8 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FConvention
9 http://en.wikibooks.org/wiki/Ada%20Programming%2FRepresentation%20clauses
10 http://en.wikipedia.org/wiki/Interrupt%20service%20routine
243
Interfacing
25.4.1 Wikibook
• Ada Programming11
• Ada Programming/Libraries/Interfaces12
11 http://en.wikibooks.org/wiki/Ada%20Programming
12 Chapter 43 on page 349
244
26 Coding Standards
26.1 Introduction
Introduction
Each project should follow a specific coding standard1 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 ASIS2 tools that can be used to check automatically the adherence of Ada
source code to the guidelines.
26.2 Tools
Tools
• AdaControl3 ( Rules4 )
• gnatcheck5 ( Rules6 )
• GNAT Pretty-Printer7
• The GNAT Metric Tool gnatmetric8
• RainCode Engine9
• RainCode Checker10
• AdaSTAT11
1 http://en.wikipedia.org/wiki/coding%20standard
2 http://en.wikipedia.org/wiki/Ada%20Semantic%20Interface%20Specification
3 http://www.adalog.fr/adacontrol2.htm
4 http://www.adalog.fr/compo/adacontrol_ug.html#Rules-reference
5 http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Verifying-Properties-Using-gnatcheck.html
6 http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Predefined-Rules.html
7 http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/The-GNAT-Pretty_002dPrinter-gnatpp.html
8 http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/The-GNAT-Metric-Tool-gnatmetric.html
9 http://www.raincode.com/adaengine.html
10 http://www.raincode.com/adachecker.html
11 http://www.adastat.com/
245
Coding Standards
Coding guidelines
. ,,
. ,,
• GNAT Coding Style: A Guide for GNAT Developers
17 . . Retrieved
18 . . Retrieved ( PDF19 )
12 http://en.wikibooks.org/wiki/Ada%20Style%20Guide
13 http://www.dit.upm.es/ork/documents/adahis.pdf
14 http://standards.iso.org/ittf/PubliclyAvailableStandards/
15 http://software.gsfc.nasa.gov/AssetsApproved/PA2.4.1.1.1.pdf
16 http://en.wikipedia.org/wiki/European%20Space%20Agency
17
18
19 http://gcc.gnu.org/onlinedocs/gnat-style.pdf
20 http://en.wikibooks.org/wiki/Ada%20Style%20Guide
246
26.4.2 Wikibook
• Ada Programming21
21 http://en.wikibooks.org/wiki/Ada%20Programming
http://geekswithblogs.net/sdorman/archive/2007/06/13/Introduction-to-Coding-Standards.
22
aspx
247
27 Tips
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 IDE1 , but it's
something some programmers learn to live with.
It turns out you don't have to. Nonchalantly mentioned in the ARM2 , 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 ABI3 .
Code sample:
package Private_And_Body is
--Operations...
private
type Body_Type; --Defined in the body
type Private_Type is access Body_Type;
end Private_And_Body;
The type in the public part is an access4 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.
1 http://en.wikipedia.org/wiki/Integrated%20development%20environment
2 http://www.adaic.org/standards/95lrm/html/RM-TTL.html
3 http://en.wikipedia.org/wiki/Application_binary_interface
4 Chapter 13 on page 99
249
Tips
These types are sometimes called "Taft types" —named after Tucker Taft, the main designer
of Ada 95— because were introduced in the so-called Taft Amendment to Ada 83. In other
programming languages, this technique is called "opaque pointer5 s".
Suppose you've decided to roll your own set6 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 generics7 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 pro-
cedures 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.
generic
type Element is private;
package Sets is
type Set is private;
[..]
generic
with procedure Apply_To_One (The_Element : in out Element);
procedure Apply_To_All (The_Set : in out Set);
end Sets;
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
5 http://en.wikipedia.org/wiki/opaque%20pointer
6 http://en.wikipedia.org/wiki/Set%20%28computer%20science%29
7 Chapter 20 on page 161
8 Functional Programming in...Ada? ˆ{http://okasaki.blogspot.com/2008/07/
functional-programming-inada.html} , by Chris Okasaki
250
to Bar. But they are both right. The reason is that selected_component is an item from
Ada's grammar (4.1.3 Selected Components ˆ{http://www.adaic.org/resources/add_
content/standards/05rm/html/RM-4-1-3.html} ). 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.
For example, if you submit the following code to the compiler,
with Pak;
package Foo is
type T is new Pak. Bar; --Oops, Pak is generic!
end 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.)
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 overlow except for machine storage
limitations), e.g.
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 not A' Length is fine; the value of A' Length
is interpreted as a modular integer since not 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
and then
251
Tips
...
--this is the same as
if (not A' Length) in Ran_6 then --not OK
...
The second conditional cannot be compiled because the expressions to the left of in is
incompatible to the type at the right. Note that not has precedence over in. It does not
negate the entire membership test but only A' Length.
The fourth conditional fails in various ways.
The sixth conditional might be fine because not turns A' Length into a modular value
which is OK if the value is covered by modular type Mod_6.
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 not in for the membership test,
if A' Length not in Ran_6 then --OK
...
See
• 2.4 Numeric Literals ˆ{http://www.adaic.org/resources/add_content/standards/
05rm/html/RM-2-4.html} ,
• 3.6.2 Operations of Array Types ˆ{http://www.adaic.org/resources/add_content/
standards/05rm/html/RM-3-6-2.html} ), and
• 4.5 Operators and Expression Evaluation ˆ{http://www.adaic.org/resources/add_
content/standards/05rm/html/RM-4-5.html} ,
• 4.5.2 Relational Operators and Membership Tests ˆ{http://www.adaic.org/
resources/add_content/standards/05rm/html/RM-4-5-2.html} ,
• Membership Tests9
27.5 I/O
252
I/O
A canonical method of reading a sequence of lines from a text file uses the standard procedure
Ada .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 Ada to prevent this and test
for End_of_Input. However, this isn't always the best choice, as has been explained for
example in a Get_Line news group discussion on comp.lang.ada10 .
A working solution uses an exception handler instead:
declare
The_Line: String( 1.. 100) ;
Last: Natural;
begin
loop
Text_IO. Get_Line( The_Line, Last) ;
--do something with The_Line ...
end loop;
exception
when Text_IO. End_Error =>
null;
end;
27.6 Quirks
Quirks
Using GNAT on Windows, calls to subprograms from Ada 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.11 As a provisional fix, it is suggested to insert
delay 0. 0;
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
10 http://groups.google.com/group/comp.lang.ada/browse_thread/thread/5afe598156615c8b#
11 Vincent Celier . Timing code blocks Timing code blocks ˆ{groups.google.es/group/comp.lang.ada/
browse_thread/thread/c8acfc87fbb1813d} . , Usenet article forwards this information from AdaCore.
253
Tips
27.7 References
References
27.8.1 Wikibook
• Ada Programming12
• Ada Programming/Errors13
12 http://en.wikibooks.org/wiki/Ada%20Programming
13 Chapter 28 on page 255
254
28 Common 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.
The compiler will not (and is not allowed by the Standard to) generate an atomic increment
instruction to directly increment and update from memory the variable A.6 This is the code
generated by the compiler:
A := A + 1;
804969f: a1 04 95 05 08 mov 0x8059504,%eax
80496a4: 40 inc %eax
80496a5: a3 04 95 05 08 mov %eax,0x8059504
1 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FAtomic
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FVolatile
3 Chapter 21 on page 173
4 Volatile: Almost Useless for Multi-Threaded Programming 5 . Intel Software Network . Retrieved
2008-05-30
6 Volatile 7 . . Retrieved 2008-05-28
8 Laurent Guerby Ada 95 Rationale . Intermetrics , , 1995
255
Common Errors
The above code snippet is equivalent to the following code (both code sequences generates
exactly the same object code), where T is a (non-atomic) temporary variable:
Thus it is incorrect to modify an atomic variable at the same time from multiple tasks.
For example, two tasks incrementing a counter in parallel. Even in an uniprocessor, other
Ada tasking features like a protected object should be used instead. In multiprocessors,
depending on the memory consistency model9 , using various atomic or volatile variables for
task communication can have surprising consequences.1012 Therefore, extreme care should
be taken when using atomic objects for task data sharing or synchronization, specially in a
multiprocessor.
28.2 References
References
It is important to realize that pragma Pack13 must not be used to specify the exact
representation of a data type, but to help the compiler to improve the efficiency of
the generated code.14 The compiler is free to ignore the pragma, therefore if a specific
representation of a type is required, representation clauses15 should be used instead (record
representation clauses, and/or attributes 'Size16 or 'Component_Size17 ).
9 http://en.wikipedia.org/wiki/Memory%20model%20%28programming%29
10 Volatile 11 . . Retrieved 2008-05-28
12 Sarita V. Adve, Kourosh Gharachorloo . Shared Memory Consistency Models: A Tutorial Shared Mem-
ory Consistency Models: A Tutorial ˆ{www.hpl.hp.com/techreports/Compaq-{}DEC/WRL-{}95-{}7.
pdf} . IEEE Computer , 29 : 66−76 December 1996
13 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPack
14 Adam Beneschan . Pragma Pack vs. Convention C, portability issue? Pragma Pack vs. Convention C,
portability issue? ˆ{groups.google.es/group/comp.lang.ada/msg/6698960624779ec7} . ,
15 http://en.wikibooks.org/wiki/Ada%20Programming%2FRepresentation%20clauses
16 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Size
17 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Component_Size
256
28.3.2 Bit-wise operations
Although in Ada 83 packed boolean arrays were used for bit-wise operations,18 since Ada 95
modular types19 are more adequate for these operations.20 The argument may be weighed
against the advantages of named Boolean array indexes such as Traffic_Lights' ( Red
=> True, others => False) , depending on use case.
A common Ada programming mistake is to assume that specifying 'Size for a type T forces
the compiler to allocate exactly this number of bits for objects of this type. This is not true.
The specified T'Size26 will force the compiler to use this size for components in
packed arrays and records and in Unchecked_Conversion, but the compiler is still
free to allocate more bits for stand-alone objects.
Use 'Size on the object itself to force the object to the specified value.
18 Software Productivity Consortium (October 1995). Ada 95 Quality and Style Guide, "10.5.7 Packed
Boolean Array Shifts ˆ{http://www.adaic.org/resources/add_content/docs/95style/html/sec_10/
10-5-7.html} "
19 Chapter 7 on page 71
20 Software Productivity Consortium (October 1995). Ada 95 Quality and Style Guide, "10.6.3 Bit Op-
erations on Modular Types ˆ{http://www.adaic.org/resources/add_content/docs/95style/html/
sec_10/10-6-3.html} "
21 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Bit%20Order
22 . . ,
23 ISO/IEC 8652:2007. 13.5.3 Bit Ordering (9/2). Ada 2005 Reference Manual. Bit_Order clauses
make it possible to write record_representation_clauses that can be ported between machines having
different bit ordering. They do not guarantee transparent exchange of data between such machines.
ˆ{http://www.adaic.org/resources/add_content/standards/05rm/html/RM-13-5-3.html}
25
24 . . Retrieved
26 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Size
257
Common Errors
See also
28.6.1 Wikibook
• Ada Programming27
• Ada Programming/Tips28
28.7 References
References
27 http://en.wikibooks.org/wiki/Ada%20Programming
28 Chapter 27 on page 249
258
29 Algorithms
29.1 Introduction
Introduction
Welcome to the Ada implementations of the Algorithms1 Wikibook. For those who are new
to Ada Programming2 a few notes:
• All examples are fully functional with all the needed input and output operations.
However, only the code needed to outline the algorithms at hand is copied into the text -
the full samples are available via the download links. (Note: It can take up to 48 hours
until the cvs is updated).
• We seldom use predefined types in the sample code but define special types suitable for
the algorithms at hand.
• Ada allows for default function parameters; however, we always fill in and name all
parameters, so the reader can see which options are available.
• We seldom use shortcuts - like using the attributes Image or Value for String <=> Integer
conversions.
All these rules make the code more elaborate than perhaps needed. However, we also hope
it makes the code easier to understand
Category:Ada Programming3
29.2.1 To Lower
The Ada example code does not append to the array as the algorithms. Instead we create
an empty array of the desired length and then replace the characters inside.
1 http://en.wikibooks.org/wiki/Algorithms
2 http://en.wikibooks.org/wiki/Ada%20Programming
3 http://en.wikibooks.org/wiki/Category%3AAda%20Programming
4 http://en.wikibooks.org/wiki/Algorithms%2FIntroduction%23Inventing%20an%20Algorithm
259
Algorithms
File: to_lower_1.adb
Would the append approach be impossible with Ada? No, but it would be significantly more
complex and slower.
File: to_lower_2.adb
260
Chapter 6: Dynamic Programming
Simple Implementation
File: fibonacci_1.adb
...
To calculate Fibonacci numbers negative values are not needed so we define an integer type
which starts at 0. With the integer type defined you can calculate up until Fib (87). Fib
(88) will result in an Constraint_Error.
You might notice that there is not equivalence for the assert (n >= 0) from the original
example. Ada will test the correctness of the parameter before the function is called.
...
Cached Implementation
File: fibonacci_2.adb
...
For this implementation we need a special cache type can also store a -1 as "not calculated"
marker
5 http://en.wikibooks.org/wiki/Algorithms%2FDynamic%20Programming%23Fibonacci_Numbers
261
Algorithms
The actual type for calculating the fibonacci numbers continues to start at 0. As it is a
subtype of the cache type Ada will automatically convert between the two. (the conversion
is - of course - checked for validity)
In order to know how large the cache need to be we first read the actual value from the
command line.
The Cache array starts with element 2 since Fib (0) and Fib (1) are constants and ends
with the value we want to calculate.
type Cache_Array is
array (Integer_Type range 2 .. Value) of Cache_Type;
The Cache is initialized to the first valid value of the cache type — this is -1.
...
This implementation is faithful to the original from the Algorithms6 book. However, in Ada
you would normally do it a little different:
File: fibonacci_3.adb
6 http://en.wikibooks.org/wiki/Algorithms
262
when you use a slightly larger array which also stores the elements 0 and 1 and initializes
them to the correct values
type Cache_Array is
array (Integer_Type range 0 .. Value) of Cache_Type;
F : Cache_Array :=
(0 => 0,
1 => 1,
others => Cache_Type'First);
return N;
els
263
Algorithms
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
264
This will save about 45% of the execution-time (measured on Linux i686) while needing only
two more elements in the cache array.
File: fibonacci_4.adb
No 64 bit integers
Your Ada compiler does not support 64 bit integer numbers? Then you could try to use
decimal numbers7 instead. Using decimal numbers results in a slower program (takes about
three times as long) but the result will be the same.
The following example shows you how to define a suitable decimal type. Do experiment
with the digits and range parameters until you get the optimum out of your Ada compiler.
File: fibonacci_5.adb
You should know that floating point numbers are unsuitable for the calculation of fibonacci
numbers. They will not report an error condition when the number calculated becomes too
large — instead they will lose in precision which makes the result meaningless.
7 Chapter 10 on page 79
265
30 Function overloading
File: function_overloading.adb
G : Random_Pack.Generator;
begin
Random_Pack.Reset (G);
return Random_Pack.Random (G);
end Generate_Number;
G : Random_Pack.Generator;
begin
Random_Pack.Reset (G);
return Random_Pack.Random (G);
end Generate_Number;
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.:
Note that you cannot overload a generic procedure or generic function within the same
package. The following example will fail to compile:
267
Function overloading
package myPackage
generic
type Value_Type is (<>);
--The first declaration of a generic subprogram
--with the name "Generic_Subprogram"
procedure Generic_Subprogram (Value : in out Value_Type);
...
generic
type Value_Type is (<>);
--This subprogram has the same name, but no
--input or output parameters. A non-generic
--procedure would be overloaded here.
--Since this procedure is generic, overloading
--is not allowed and this package will not compile.
procedure Generic_Subprogram;
...
generic
type Value_Type is (<>);
--The same situation.
--Even though this is a function and not
--a procedure, generic overloading of
--the name "Generic_Subprogram" is not allowed.
function Generic_Subprogram (Value : Value_Type) return Value_Type;
end myPackage;
30.2.1 Wikibook
• Ada Programming1
• Ada Programming/Subprograms2
1 http://en.wikibooks.org/wiki/Ada%20Programming
2 Chapter 16 on page 125
268
31 Mathematical calculations
Ada is very well suited for all kind of calculations. You can define you 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 Fortran1 . This module will show you
how to use them and while we progress we create a simple RPN2 calculator.
31.1.1 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:
File: numeric_1.adb
procedure Numeric_1 is
type Value_Type is digits 12
range -999_999_999_999.0e999 .. 999_999_999_999.0e999;
Value_1 : Value_Type;
Value_2 : Value_Type;
begin
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);
end Numeric_1;
1 http://en.wikibooks.org/wiki/Programming%3AFortran
2 http://en.wikipedia.org/wiki/Reverse%20Polish%20notation
269
Mathematical calculations
31.1.2 Subtraction
Subtractions can be done using the predefined operator - . The following extended demo
shows the use of + and - operator together:
File: numeric_2.adb
procedure Numeric_2
is
type Value_Type
is digits
12
range
-999_999_999_999.0e999 .. 999_999_999_999.0e999;
Value_1 : Value_Type;
Value_2 : Value_Type;
Result : Value_Type;
Operation : Character;
begin
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);
case Operation is
when '+' =>
Result := Value_1 + Value_2;
when '-' =>
Result := Value_1 - Value_2;
when others =>
T_IO.Put_Line ("Illegal Operation.");
goto Exit_Numeric_2;
end case;
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>>
return;
end Numeric_2;
270
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 evil5 article.
31.1.3 Multiplication
Multiplication can be done using the predefined operator * . For a demo see the next chapter
about Division.
31.1.4 Division
Divisions can be done using the predefined operators / , mod , rem . The operator /
performs a normal division, mod returns a modulus division and rem 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 mod and rem are not part of the demonstration as they are only defined for
integer types.
File: numeric_3.adb
with Ada ;
procedure Numeric_3 is
procedure Pop_Value;
procedure Push_Value;
procedure Pop_Value is
begin
Values (Values'First + 1 .. Values'Last) :=
Values (Values'First + 2 .. Values'Last) & 0.0;
end Pop_Value;
procedure Push_Value is
begin
Values (Values'First + 1 .. Values'Last) :=
Values (Values'First .. Values'Last - 1);
end Push_Value;
5 Chapter 4 on page 37
271
Mathematical calculations
begin
Main_Loop:
loop
T_IO.Put (">");
T_IO.Get_Line (Operation, Last);
Display_Loop:
for I in reverse Value_Array'Range loop
F_IO.Put
(Item => Values (I),
Fore => F_IO.Default_Fore,
Aft => F_IO.Default_Aft,
Exp => 4);
T_IO.New_Line;
end loop Display_Loop;
end loop Main_Loop;
return;
end Numeric_3;
All exponential functions are defined inside the generic package Ada .
31.2.1 Power of
Calculation of the form xy 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 Ada .
272
31.2.2 Root
√
The square root x is calculated with the function Sqrt(). There is no function defined to
√
calculate an arbitrary root n x. However you can use logarithms to calculate an arbitrary
√
root using the mathematical identity: b a = eloge (a)/b which will become root := Exp (Log
√ 1
(a) / b) in Ada. Alternatively, use b a = a b which, in Ada, is root := a**(1.0/b).
31.2.3 Logarithm
Ada defines a function for both the arbitrary logarithm logn (x) and the natural logarithm
loge (x), both of which have the same name Log() distinguished by the number of parameters.
31.2.4 Demonstration
The following extended demo shows the how to use the exponential functions in Ada. The
new demo also uses Unbounded_String6 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.
File: numeric_4.adb
with Ada ;
with Ada ;
with Ada ;
procedure Numeric_4 is
package Str renames Ada.Strings.Unbounded;
package T_IO renames Ada.Text_IO;
procedure Pop_Value;
procedure Push_Value;
function Get_Line return Str.Unbounded_String;
use Value_Functions;
use type Str.Unbounded_String;
6 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Unbounded
273
Mathematical calculations
return Retval;
end Get_Line;
...
begin
Main_Loop :
loop
T_IO.Put (">");
Operation := Get_Line;
...
elsif Operation = "e" then
-- insert e
Push_Value;
Values (1) := Ada.Numerics.e;
elsif Operation = "**" or else Operation = "ˆ" then
-- power of xˆy
Values (1) := Values (1) ** Values (2);
Pop_Value;
elsif Operation = "sqr" then
-- square root
Values (1) := Sqrt (Values (1));
elsif Operation = "root" then
-- arbritary root
Values (1) :=
Exp (Log (Values (2)) / Values (1));
Pop_Value;
elsif Operation = "ln" then
-- natural logarithm
Values (1) := Log (Values (1));
elsif Operation = "log" then
-- based logarithm
Values (1) :=
Log (Base => Values (1), X => Values (2));
Pop_Value;
elsif Operation = "exit" then
exit Main_Loop;
else
Push_Value;
F_IO.Get
(From => Str.To_String (Operation),
Item => Values (1),
Last => Dummy);
end if;
...
end loop Main_Loop;
274
return;
end Numeric_4;
The full set of trigonometric7 functions are defined inside the generic package Ada . 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.
File: numeric_5.adb
with Ada ;
with Ada ;
with Ada ;
procedure Numeric_5 is
...
use Value_Functions;
use type Str.Unbounded_String;
...
7 http://en.wikibooks.org/wiki/%2FTrigonometry
275
Mathematical calculations
T_IO.New_Line;
return;
end Put_Line;
...
begin
Main_Loop :
loop
Display_Loop :
for I in reverse Value_Array'Range loop
Put_Line (Values (I));
end loop Display_Loop;
T_IO.Put (">");
Operation := Get_Line;
...
elsif Operation = "deg" then
-- switch to degrees
Cycle := 360.0;
elsif Operation = "rad" then
-- switch to degrees
Cycle := Ada.Numerics.Pi;
elsif Operation = "grad" then
-- switch to degrees
Cycle := 400.0;
elsif Operation = "pi" or else Operation = "" then
-- switch to degrees
Push_Value;
Values (1) := Ada.Numerics.Pi;
elsif Operation = "sin" then
-- sinus
Values (1) := Sin (X => Values (1), Cycle => Cycle);
elsif Operation = "cos" then
-- cosinus
Values (1) := Cos (X => Values (1), Cycle => Cycle);
elsif Operation = "tan" then
-- tangents
Values (1) := Tan (X => Values (1), Cycle => Cycle);
elsif Operation = "cot" then
-- cotanents
Values (1) := Cot (X => Values (1), Cycle => Cycle);
elsif Operation = "asin" then
-- arc-sinus
Values (1) := Arcsin (X => Values (1), Cycle => Cycle);
elsif Operation = "acos" then
-- arc-cosinus
Values (1) := Arccos (X => Values (1), Cycle => Cycle);
elsif Operation = "atan" then
-- arc-tangents
Values (1) := Arctan (Y => Values (1), Cycle => Cycle);
elsif Operation = "acot" then
-- arc-cotanents
Values (1) := Arccot (X => Values (1), Cycle => Cycle);
...
end loop Main_Loop;
return;
end Numeric_5;
The Demo also contains an improved numeric output which behaves more like a normal
calculator.
276
31.3.2 Hyperbolic calculations
You guessed it: The full set of hyperbolic functions is defined inside the generic package Ada .
File: numeric_6.adb
with Ada ;
with Ada ;
with Ada ;
with Ada ;
procedure Numeric_6 is
package Str renames Ada.Strings.Unbounded;
package T_IO renames Ada.Text_IO;
package Exept renames Ada.Exceptions;
...
begin
Main_Loop :
loop
Try :
begin
Display_Loop :
...
elsif Operation = "sinh" then
-- sinus hyperbolic
Values (1) := Sinh (Values (1));
elsif Operation = "cosh" then
-- cosinus hyperbolic
Values (1) := Coth (Values (1));
elsif Operation = "tanh" then
-- tangents hyperbolic
Values (1) := Tanh (Values (1));
elsif Operation = "coth" then
-- cotanents hyperbolic
Values (1) := Coth (Values (1));
elsif Operation = "asinh" then
-- arc-sinus hyperbolic
Values (1) := Arcsinh (Values (1));
elsif Operation = "acosh" then
-- arc-cosinus hyperbolic
Values (1) := Arccosh (Values (1));
elsif Operation = "atanh" then
-- arc-tangents hyperbolic
Values (1) := Arctanh (Values (1));
elsif Operation = "acoth" then
-- arc-cotanents hyperbolic
Values (1) := Arccoth (Values (1));
...
exception
when An_Exception : others =>
T_IO.Put_Line
(Exept.Exception_Information (An_Exception));
end Try;
end loop Main_Loop;
return;
end Numeric_6;
277
Mathematical calculations
As added bonus this version supports error handling and therefore won't just crash when an
illegal calculation is performed.
For complex arithmetic8 Ada provides the package Ada . 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 (+ , - , * ) operators have their usual meaning
as soon as the package Ada has been instantiated (package ... is new ...) and the type has
been made visible (use type ...)
Ada also provides the packages Ada and Ada which provide similar functionality to their
normal counterparts. But there are some differences:
• Ada supports only the exponential and trigonometric functions which make sense in
complex arithmetic.
• Ada is a child package of Ada and therefore needs its own with. Note: the Ada 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:
File: numeric_7.adb
with Ada.Text_IO.Complex_IO;
with Ada.Numerics.Generic_Complex_Types;
with Ada.Numerics.Generic_Complex_Elementary_Functions;
with Ada.Strings.Unbounded;
with Ada.Exceptions;
procedure Numeric_7 is
...
type Value_Array is
array (Natural range 1 .. 4) of Complex_Types.Complex;
8 http://en.wikibooks.org/wiki/Algebra%2FComplex%20Numbers
278
use Complex_Functions;
Values : Value_Array :=
(others => Complex_Types.Complex'(Re => 0.0, Im => 0.0));
...
return;
end Put_Line;
begin
...
elsif Operation = "e" then
-- insert e
Push_Value;
Values (1) :=
Complex_Types.Complex'(Re => Ada.Numerics.e, Im
=> 0.0);
...
279
Mathematical calculations
...
return;
end Numeric_7;
Ada supports vector9 and matrix10 Arithmetic for both normal real types and com-
plex 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 ...
File: numeric_8-complex_calculator.ada
File: numeric_8-get_line.ada
File: numeric_8-real_calculator.ada
File: numeric_8-real_vector_calculator.ada
31.4.1 Wikibook
• Ada Programming11
9 http://en.wikibooks.org/wiki/Linear%20Algebra%2FVectors%20in%20Space
10 http://en.wikibooks.org/wiki/Linear_Algebra%2FDescribing_the_Solution_Set%23matrix
11 http://en.wikibooks.org/wiki/Ada%20Programming
280
• Ada Programming/Delimiters/-12
• Ada Programming/Libraries/Ada.Numerics.Generic_Complex_Types13
• Ada Programming/Libraries/Ada.Numerics.Generic_Elementary_Functions14
12 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F-
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Generic_
13
Complex_Types
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Generic_
14
Elementary_Functions
281
32 Statements
Note: there are some simplifications in the explanations below. Don't take anything too
literally.
Most programming languages have the concept of a statement. A statement is a
command that the programmer gives to the computer. For example:
This command has a verb ("") and other details (what to print). In this case, the command
"" means "show on the screen," not "print on the printer." The programmer either gives
the statement directly to the computer (by typing it while running a special program),
or creates a text file with the command in it. You could create a file called "hi.txt", put
the above command in it, and give the file to the computer.
If you have more than one command in the file, each will be performed in order, top to
bottom. So the file could contain:
This does seem like a lot of typing but don't worry: Ada allows you to declare shorter
aliasnames if you need a long statement very often.
283
33 Variables
Variables are references that stand in for a value that is contained at a certain memory
address.
Variables are said to have a value and may have a data type1 . If a variable has a type,
then only values of this type may be assigned to it. Variables do not always have a type.
A value can have many values of many different types: integers (7), ratios (1/2), (approx-
imations of) reals (10.234), complex numbers (4+2i), characters ('a'), strings ("hello"),
and much more.
Different languages use different names for their types and may not include any of the
above.
X =3 10;
declare
X : Integer =5 10;
begin
Do_Something (X);
end;
33.2 Uses
Uses
Variables store everything in your program. The purpose of any useful program is to
modify variables.
1 http://en.wikibooks.org/wiki/Computer%20Programming%2FTypes
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%3A%3D
4 http://en.wikibooks.org/wiki/Template%3AComputer%20Programming%2FVariables%2F2
285
Variables
See also
286
34 Lexical elements
1 http://en.wikipedia.org/wiki/ISO%208859-1
2 Chapter 23 on page 219
3 http://en.wikipedia.org/wiki/Unicode
4 Chapter 36 on page 297
5 Chapter 35 on page 293
287
Lexical elements
34.2.1 Identifiers
Definition in BNF6 :
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:
Exercise: could you give the reason for not being legal for each one of them?
34.2.2 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 1012 , that is 510 ; a hexadecimal number with exponent
is 16#B#E2, that is 11 × 162 = 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.
6 http://en.wikipedia.org/wiki/Backus-Naur%20form
288
34.2.3 Character literals
Their type is Standard .Character, Wide_Character or Wide_Wide_Character. They
are delimited by an apostrophe (')7 .
Examples:
34.2.5 Delimiters
Single delimiters are one of the following special characters:
Compound delimiters are composed of two special characters, and they are the following
ones:
34.2.6 Comments
Comments in Ada start with two consecutive hyphens (--) and end in the end of line.
7 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%27
8 Chapter 15 on page 119
9 http://en.wikibooks.org/wiki/Ada%20Programming%2FSpecial%2F%22
10 Chapter 36 on page 297
289
Lexical elements
Ada Keywords12
abort else new return
abs elsif not reverse
abstract (Ada 95) end null
accept entry select
access exception of separate
aliased (Ada 95) exit or some
(Ada 2012)
all others subtype
and for out synchronized
(Ada 2005)
array function overriding
(Ada 2005)
at tagged
(Ada 95)
generic package task
begin goto pragma terminate
body private then
if procedure type
case in protected
(Ada 95)
constant interface until
(Ada 2005) (Ada 95)
is raise use
declare range
delay limited record when
delta loop rem while
digits renames with
do mod requeue xor
(Ada 95)
290
See also
34.3.1 Wikibook
• Ada Programming13
• Ada Programming/Delimiters14
• Ada Programming/Keywords15
13 http://en.wikibooks.org/wiki/Ada%20Programming
14 Chapter 36 on page 297
15 Chapter 35 on page 293
16 http://es.wikibooks.org/wiki/Programaci%F3n%20en%20Ada%2FElementos%20del%20lenguaje
291
35 Keywords
35.1 Language summary keywords
Language summary keywords
Most Ada “keywords” have different functions depending on where they are used. A good
example is for1 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 attribute2 names.
Ada Keywords3
1 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Ffor
2 Chapter 38 on page 305
3 http://en.wikibooks.org/wiki/Ada%20Programming%2FAll%20Keywords
293
Keywords
35.3.1 Wikibook
• Ada Programming4
• Ada Programming/Aspects5
• Ada Programming/Attributes6
• Ada Programming/Pragmas7
4 http://en.wikibooks.org/wiki/Ada%20Programming
5 http://en.wikibooks.org/wiki/Ada%20Programming%2FAspects
6 Chapter 38 on page 305
7 Chapter 39 on page 317
294
35.3.2 Ada Reference Manual
Ada 83
• Annex 2: Reserved Words ˆ{http://archive.adaic.com/standards/83lrm/html/
lrm-2.html}
• Annex E: Syntax Summary ˆ{http://archive.adaic.com/standards/83lrm/html/
lrm-E.html}
Ada 95
• 2.9 Reserved Words8
• Annex P: (informative) Syntax Summary9
Ada 2005
• 2.9 Reserved Words10
• Annex P: (informative) Syntax Summary11
Ada 2012
• 2.9 Reserved Words12
• Annex P: (informative) Syntax Summary13
8 http://www.adaic.org/resources/add_content/standards/95lrm/ARM_HTML/RM-2-9.html
9 http://www.adaic.org/resources/add_content/standards/95lrm/ARM_HTML/RM-P.html
10 http://www.adaic.org/resources/add_content/standards/05rm/html/RM-2-2-9.html
11 http://www.adaic.org/resources/add_content/standards/05rm/html/RM-2-P.html
12 http://www.ada-auth.org/standards/12rm/html/RM-2-9.html
13 http://www.ada-auth.org/standards/12rm/html/RM-P.html
295
36 Delimiters
36.1 Single character delimiters
Single character delimiters
&1
ampersand (also operator &2 )
' 3
apostrophe, tick
( 4
left parenthesis
)5
right parenthesis
*6
asterisk, multiply (also operator *7 )
+8
plus sign (also operator +9 )
,10
comma
- 11
colon
;17
1 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%26
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%26
3 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%27
4 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%28
5 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%29
6 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2A
7 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2F%2A
8 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2B
9 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2B
10 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2C
11 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F-
12 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2F-
13 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Fdot
14 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2F
15 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2F%2F
16 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%3A
17 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%3B
297
Delimiters
semicolon
<18
less than sign (also operator)
=19
equal sign (also operator =20 )
>21
greater than sign (also operator)
22
vertical line
=>23
arrow
..24
double dot
**25
double star, exponentiate (also operator **26 )
=27
assignment
/=28
inequality (also operator)
>=29
greater than or equal to (also operator)
<=30
less than or equal to (also operator)
<<31
left label bracket
>>32
right label bracket
<>33
18 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Fless%20than
19 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%3D
20 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2F%3D
21 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Fgreater%20than
22 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Fvertical%20line
23 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Farrow
24 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Fdouble%20dot
25 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2A%2A
26 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2F%2A%2A
27 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%3A%3D
28 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2F%3D
http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Fgreater%20than%20or%
29
20equal%20to
http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Fless%20than%20or%
30
20equal%20to
31 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Fleft%20label
32 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Fright%20label
33 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Fbox
298
box
36.3 Others
Others
36.4.1 Wikibook
• Ada Programming38
34 http://en.wikibooks.org/wiki/Ada%20Programming%2FSpecial%2F%22
35 Chapter 34.2.4 on page 289
36 http://en.wikibooks.org/wiki/Ada%20Programming%2FSpecial%2Fnumber%20sign
37 Chapter 34.2.2 on page 288
38 http://en.wikibooks.org/wiki/Ada%20Programming
299
37 Operators
Ada1 allows operator overloading2 for all standard operators and so the following sum-
maries 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 keyword3 or a delimiter4 -- hence all operator pages are redirects
to the appropriate keyword5 or delimiter6 .
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.
1 http://en.wikibooks.org/wiki/Ada%20Programming
2 http://en.wikipedia.org/wiki/operator%20overloading
3 Chapter 35 on page 293
4 Chapter 36 on page 297
5 Chapter 35 on page 293
6 Chapter 36 on page 297
7 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2Fand
8 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Fand
9 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2For
10 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2For
11 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2Fxor
12 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Fxor
13 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2F%2F%3D
14 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2F%3D
15 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2F%3D
16 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%3D
301
Operators
<17
Less than x < y, (also special character <18 )
<=19
Less than or equal to (x ≤ y), (also special character <=20 )
>21
Greater than (x > y), (also special character >22 )
>=23
Greater than or equal to (x ≥ y), (also special character >=24 )
17 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2Fless%20than
18 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Fless%20than
http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2Fless%20than%20or%
19
20equal%20to
http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Fless%20than%20or%
20
20equal%20to
21 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2Fgreater%20than
22 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Fgreater%20than
http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2Fgreater%20than%20or%
23
20equal%20to
http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2Fgreater%20than%20or%
24
20equal%20to
25 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2B
26 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2B
27 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F-
28 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F-
29 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%26
30 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%26
31 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2B
32 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2B
33 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F-
34 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F-
35 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2A
36 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2A
302
/37
Divide x/y, (also special character /38 )
mod39
modulus (also keyword mod40 )
rem41
remainder (also keyword rem42 )
The Membership Tests also cannot be overloaded because they are not operators.
in51
element of, var ∈ type, e.g. if I in Positive then, (also keyword in)
not in52
37 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2F
38 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2F
39 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2Fmod
40 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Fmod
41 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Frem
42 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Frem
43 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2A%2A
44 http://en.wikibooks.org/wiki/Ada%20Programming%2FDelimiters%2F%2A%2A
45 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2Fnot
46 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Fnot
47 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2Fabs
48 http://en.wikibooks.org/wiki/Ada%20Programming%2FKeywords%2Fabs
http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2Fand%23Boolean_shortcut_
49
operator
http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2For%23Boolean_shortcut_
50
operator
51 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2Fin
52 http://en.wikibooks.org/wiki/Ada%20Programming%2FOperators%2Fin
303
Operators
Is_Non_Negative := X in Natural;
37.4.1 Wikibook
• Ada Programming53
Ada Operators54
and55 and then56 >57 +58 abs59 &60
or61 or else62 >=63 -64 mod65
xor 66 =67 <68 *69 rem70 in71
not 72 /=73 <=74 **75 /76 not in77
53 http://en.wikibooks.org/wiki/Ada%20Programming
54 http://en.wikibooks.org/wiki/Ada%20Programming%2FAll%20Operators
304
38 Attributes
The concept of attributes is pretty unique to Ada1 . Attributes allow you to get —and
sometimes set— information about objects or other language entities such as types. A
good example is the Size attribute. It describes the size of an object or a type in bits.
A : Natural := Integer'Size; --A is now 32 (with the GNAT2 compiler for the x86 architecture)
However, unlike the sizeof operator from C3 /C++4 the Size attribute can also be set:
type Byte is range -128 .. 127; --The range fits into 8 bits but the
--compiler is still free to choose.
for Byte'Size use 8; --Now we force the compiler to use 8 bits.
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 or of a character literal.
Ada 2005
This is a new Ada 20055 attribute.
Ada 2012
This is a new Ada 20126 attribute.
Obsolescent
This is a deprecated attribute and should not be used in new code.
1 http://en.wikibooks.org/wiki/Ada%20Programming
3 http://en.wikibooks.org/wiki/C%20Programming
4 http://en.wikibooks.org/wiki/C%2B%2B%20Programming
5 Chapter 23 on page 219
6 http://en.wikibooks.org/wiki/Ada%20Programming%2FAda%202012
305
Attributes
38.2.1 A − B
• 'Access7
• 'Address8
• 'Adjacent9
• 'Aft10
• 'Alignment11
• 'Base12
• 'Bit_Order13
• 'Body_Version14
38.2.2 C
• 'Callable15
• 'Caller16
• 'Ceiling17
• 'Class18
• 'Component_Size19
• 'Compose20
• 'Constrained21
• 'Copy_Sign22
• 'Count23
38.2.3 D − F
• 'Definite24
• 'Delta25
• 'Denorm26
• 'Digits27
• 'Emax28 (Obsolescent)
7 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Access
8 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Address
9 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Adjacent
10 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Aft
11 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Alignment
12 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Base
13 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Bit_Order
14 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Body_Version
15 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Callable
16 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Caller
17 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Ceiling
18 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Class
19 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Component_Size
20 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Compose
21 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Constrained
22 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Copy_Sign
23 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Count
24 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Definite
25 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Delta
26 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Denorm
27 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Digits
28 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Emax
306
• 'Exponent29
• 'External_Tag30
• 'Epsilon31 (Obsolescent)
• 'First32
• 'First_Bit33
• 'Floor34
• 'Fore35
• 'Fraction36
38.2.4 G − L
• 'Has_Same_Storage37 (Ada 2012)
• 'Identity38
• 'Image39
• 'Input40
• 'Large41 (Obsolescent)
• 'Last42
• 'Last_Bit43
• 'Leading_Part44
• 'Length45
38.2.5 M
• 'Machine46
• 'Machine_Emax47
• 'Machine_Emin48
• 'Machine_Mantissa49
• 'Machine_Overflows50
29 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Exponent
30 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27External_Tag
31 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Epsilon
32 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27First
33 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27First_Bit
34 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Floor
35 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Fore
36 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Fraction
37 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Has_Same_Storage
38 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Identity
39 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Image
40 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Input
41 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Large
42 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Last
43 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Last_Bit
44 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Leading_Part
45 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Length
46 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Machine
47 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Machine_Emax
48 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Machine_Emin
49 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Machine_Mantissa
50 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Machine_Overflows
307
Attributes
• 'Machine_Radix51
• 'Machine_Rounding52 (Ada 2005)
• 'Machine_Rounds53
• 'Mantissa54 (Obsolescent)
• 'Max55
• 'Max_Aligment_For_Allocation56 (Ada 2012)
• 'Max_Size_In_Storage_Elements57
• 'Min58
• 'Mod59 (Ada 2005)
• 'Model60
• 'Model_Emin61
• 'Model_Epsilon62
• 'Model_Mantissa63
• 'Model_Small64
• 'Modulus65
38.2.6 O − R
• 'Old66 (Ada 2012)
• 'Output67
• 'Overlaps_Storage68 (Ada 2012)
• 'Partition_ID69
• 'Pos70
• 'Position71
• 'Pred72
• 'Priority73 (Ada 2005)
51 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Machine_Radix
52 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Machine_Rounding
53 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Machine_Rounds
54 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Mantissa
55 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Max
http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Max_Aligment_For_
56
Allocation
http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Max_Size_In_Storage_
57
Elements
58 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Min
59 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Mod
60 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Model
61 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Model_Emin
62 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Model_Epsilon
63 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Model_Mantissa
64 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Model_Small
65 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Modulus
66 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Old
67 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Output
68 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Overlaps_Storage
69 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Partition_ID
70 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Pos
71 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Position
72 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Pred
73 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Priority
308
• 'Range74
• 'Read75
• 'Remainder76
• 'Result77 (Ada 2012)
• 'Round78
• 'Rounding79
38.2.7 S
• 'Safe_Emax80 (Obsolescent)
• 'Safe_First81
• 'Safe_Large82 (Obsolescent)
• 'Safe_Last83
• 'Safe_Small84 (Obsolescent)
• 'Scale85
• 'Scaling86
• 'Signed_Zeros87
• 'Size88
• 'Small89
• 'Storage_Pool90
• 'Storage_Size91
• 'Stream_Size92 (Ada 2005)
• 'Succ93
38.2.8 T − V
• 'Tag94
• 'Terminated95
74 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Range
75 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Read
76 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Remainder
77 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Result
78 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Round
79 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Rounding
80 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Safe_Emax
81 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Safe_First
82 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Safe_Large
83 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Safe_Last
84 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Safe_Small
85 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Scale
86 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Scaling
87 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Signed_Zeros
88 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Size
89 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Small
90 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Storage_Pool
91 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Storage_Size
92 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Stream_Size
93 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Succ
94 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Tag
95 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Terminated
309
Attributes
• 'Truncation96
• 'Unbiased_Rounding97
• 'Unchecked_Access98
• 'Val99
• 'Valid100
• 'Value101
• 'Version102
38.2.9 W − Z
• 'Wide_Image103
• 'Wide_Value104
• 'Wide_Wide_Image105 (Ada 2005)
• 'Wide_Wide_Value106 (Ada 2005)
• 'Wide_Wide_Width107 (Ada 2005)
• 'Wide_Width108
• 'Width109
• 'Write110
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 adding111 specific attributes of other compilers:
GNAT
Implementation-defined attribute112 of the GNAT113 compiler from AdaCore/FSF.
HP Ada
96 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Truncation
97 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Unbiased_Rounding
98 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Unchecked_Access
99 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Val
100 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Valid
101 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Value
102 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Version
103 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Wide_Image
104 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Wide_Value
105 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Wide_Wide_Image
106 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Wide_Wide_Value
107 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Wide_Wide_Width
108 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Wide_Width
109 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Width
110 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Write
111 http://en.wikibooks.org/w/index.php?title=Programming:Ada:Attributes&action=edit
112 http://www.adacore.com/wp-content/files/auto_update/gnat-unw-docs/html/gnat_rm_3.html
113 http://en.wikibooks.org/wiki/Ada%20Programming%2FGNAT
310
Implementation-defined attribute114 of the HP Ada115 compiler (formerly known as
"DEC Ada").
ICC
Implementation-defined attribute116 of the Irvine ICC117 compiler.
PowerAda
Implementation-defined attribute118 of OC Systems' PowerAda119 .
SPARCompiler
Implementation-defined attribute120 of Sun's SPARCompiler Ada121 .
38.3.1 A − D
• 'Abort_Signal122 (GNAT)
• 'Address_Size123 (GNAT)
• 'Architecture124 (ICC)
• 'Asm_Input125 (GNAT)
• 'Asm_Output126 (GNAT)
• 'AST_Entry127 (GNAT, HP Ada)
• 'Bit128 (GNAT, HP Ada)
• 'Bit_Position129 (GNAT)
• 'CG_Mode130 (ICC)
• 'Code_Address131 (GNAT)
• 'Compiler_Key132 (SPARCompiler)
• 'Compiler_Version133 (SPARCompiler)
• 'Declared134 (ICC)
• 'Default_Bit_Order135 (GNAT)
• 'Dope_Address136 (SPARCompiler)
114 http://h71000.www7.hp.com/commercial/ada/ada_lrm.pdf
115 http://h71000.www7.hp.com/commercial/ada/ada_index.html
116 "4.2 ICC-Defined Attributes", ICC Ada Implementation Reference — ICC Ada Version 8.2.5 for i960MC
Targets, document version 2.11.4http://www.irvine.com/support/general/
117 http://www.irvine.com/products.html
118 http://www.ocsystems.com/user_guide/powerada/html/powerada-117.html#HEADING117-0
119 http://www.ocsystems.com/prod_powerada.html
http://docs.sun.com/app/docs/doc/802-3641/6i7h8si5i?a=view#F.
120
Implementation-Dependent_Characteristi-30
121 http://docs.sun.com/app/docs/coll/15.4
122 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Abort_Signal
123 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Address_Size
124 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Architecture
125 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Asm_Input
126 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Asm_Output
127 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27AST_Entry
128 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Bit
129 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Bit_Position
130 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27CG_Mode
131 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Code_Address
132 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Compiler_Key
133 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Compiler_Version
134 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Declared
135 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Default_Bit_Order
136 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Dope_Address
311
Attributes
• 'Dope_Size137 (SPARCompiler)
38.3.2 E − H
• 'Elaborated138 (GNAT)
• 'Elab_Body139 (GNAT)
• 'Elab_Spec140 (GNAT)
• 'Emax141 (GNAT)
• 'Enabled142 (GNAT)
• 'Entry_Number143 (SPARCompiler)
• 'Enum_Rep144 (GNAT)
• 'Enum_Val145 (GNAT)
• 'Epsilon146 (GNAT)
• 'Exception_Address147 (ICC)
• 'Extended_Aft148 (PowerAda)
• 'Extended_Base149 (PowerAda)
• 'Extended_Digits150 (PowerAda)
• 'Extended_Fore151 (PowerAda)
• 'Extended_Image152 (PowerAda)
• 'Extended_Value153 (PowerAda)
• 'Extended_Width154 (PowerAda)
• 'Extended_Wide_Image155 (PowerAda)
• 'Extended_Wide_Value156 (PowerAda)
• 'Extended_Wide_Width157 (PowerAda)
• 'Fixed_Value158 (GNAT)
• 'Has_Access_Values159 (GNAT)
• 'Has_Discriminants160 (GNAT)
137 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Dope_Size
138 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Elaborated
139 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Elab_Body
140 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Elab_Spec
141 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Emax
142 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Enabled
143 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Entry_Number
144 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Enum_Rep
145 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Enum_Val
146 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Epsilon
147 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Exception_Address
148 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Extended_Aft
149 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Extended_Base
150 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Extended_Digits
151 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Extended_Fore
152 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Extended_Image
153 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Extended_Value
154 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Extended_Width
155 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Extended_Wide_Image
156 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Extended_Wide_Value
157 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Extended_Wide_Width
158 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Fixed_Value
159 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Has_Access_Values
160 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Has_Discriminants
312
• 'High_Word161 (ICC)
• 'Homogeneous162 (SPARCompiler)
38.3.3 I − N
• 'Img163 (GNAT)
• 'Integer_Value164 (GNAT)
• 'Invalid_Value165 (GNAT)
• 'Linear_Address166 (ICC)
• 'Low_Word167 (ICC)
• 'Machine_Size168 (GNAT, HP Ada)
• 'Max_Interrupt_Priority169 (GNAT)
• 'Max_Priority170 (GNAT)
• 'Maximum_Alignment171 (GNAT)
• 'Mechanism_Code172 (GNAT)
• 'Null_Parameter173 (GNAT, HP Ada)
38.3.4 O − T
• 'Object_Size174 (GNAT)
• 'Old175 (GNAT)
• 'Passed_By_Reference176 (GNAT)
• 'Pool_Address177 (GNAT)
• 'Range_Length178 (GNAT)
• 'Ref179 (SPARCompiler)
• 'Storage_Unit180 (GNAT)
• 'Stub_Type181 (GNAT)
• 'Target182 (ICC)
161 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27High_Word
162 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Homogeneous
163 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Img
164 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Integer_Value
165 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Invalid_Value
166 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Linear_Address
167 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Low_Word
168 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Machine_Size
http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Max_Interrupt_
169
Priority
170 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Max_Priority
171 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Maximum_Alignment
172 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Mechanism_Code
173 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Null_Parameter
174 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Object_Size
175 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Old
176 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Passed_By_Reference
177 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Pool_Address
178 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Range_Length
179 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Ref
180 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Storage_Unit
181 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Stub_Type
182 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Target
313
Attributes
• 'Target_Name183 (GNAT)
• 'Task_ID184 (SPARCompiler)
• 'Tick185 (GNAT)
• 'To_Address186 (GNAT)
• 'Type_Class187 (GNAT, HP Ada)
• 'Type_Key188 (SPARCompiler)
38.3.5 U − Z
• 'UET_Address189 (GNAT)
• 'Unconstrained_Array190 (GNAT)
• 'Universal_Literal_String191 (GNAT)
• 'Unrestricted_Access192 (GNAT, ICC)
• 'VADS_Size193 (GNAT)
• 'Value_Size194 (GNAT)
• 'Wchar_T_Size195 (GNAT)
• 'Word_Size196 (GNAT)
38.4.1 Wikibook
• Ada Programming197
• Ada Programming/Aspects198
• Ada Programming/Pragmas199
• Ada Programming/Keywords200
183 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Target_Name
184 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Task_ID
185 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Tick
186 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27To_Address
187 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Type_Class
188 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Type_Key
189 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27UET_Address
190 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Unconstrained_Array
http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Universal_Literal_
191
String
192 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Unrestricted_Access
193 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27VADS_Size
194 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Value_Size
195 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Wchar_T_Size
196 http://en.wikibooks.org/wiki/Ada%20Programming%2FAttributes%2F%27Word_Size
197 http://en.wikibooks.org/wiki/Ada%20Programming
198 http://en.wikibooks.org/wiki/Ada%20Programming%2FAspects
199 Chapter 39 on page 317
200 Chapter 35 on page 293
314
38.4.2 Ada Reference Manual
Ada 83
• Annex 4: Attributes ˆ{http://archive.adaic.com/standards/83lrm/html/lrm-4.
html}
• Annex A: Predefined Language Attributes ˆ{http://archive.adaic.com/
standards/83lrm/html/lrm-A.html}
Ada 95
• 4.1 Attributes201
• Annex K: (informative) Language-Defined Attributes202
Ada 2005
• 4.1 Attributes203
• Annex K: (informative) Language-Defined Attributes204
Ada 2012
• 4.1 Attributes205
• Annex K: (informative) Language-Defined Attributes206
38.5 References
References
201 http://www.adaic.org/resources/add_content/standards/95lrm/ARM_HTML/RM-4-1.html
202 http://www.adaic.org/resources/add_content/standards/95lrm/ARM_HTML/RM-K.html
203 http://www.adaic.org/resources/add_content/standards/05rm/html/RM-2-4-1.html
204 http://www.adaic.org/resources/add_content/standards/05rm/html/RM-2-K.html
205 http://www.ada-auth.org/standards/12rm/html/RM-4-1.html
206 http://www.ada-auth.org/standards/12rm/html/RM-K.html
315
39 Pragmas
39.1 Description
Description
Pragmas1 control the compiler, i.e. they are compiler directives2 . They have the standard
form of
39.2.1 A − H
• All_Calls_Remote5
• Assert6 (Ada 2005)
• Assertion_Policy7 (Ada 2005)
• Asynchronous8 (Obsolescent since Ada 2012)
• Atomic9 (Obsolescent since Ada 2012)
• Atomic_Components10 (Obsolescent since Ada 2012)
• Attach_Handler11 (Obsolescent since Ada 2012)
317
Pragmas
• Controlled12
• Convention13 (Obsolescent since Ada 2012)
• CPU14 (Ada 2012)
• Default_Storage_Pool15 (Ada 2012)
• Detect_Blocking16 (Ada 2005)
• Discard_Names17
• Dispatching_Domain18 (Ada 2012)
• Elaborate19
• Elaborate_All20
• Elaborate_Body21
• Export22 (Obsolescent since Ada 2012)
39.2.2 I − O
• Import23 (Obsolescent since Ada 2012)
• Independent24 (Ada 2012)
• Independent_Component25 (Ada 2012)
• Inline26 (Obsolescent since Ada 2012)
• Inspection_Point27
• Interface28 (Obsolescent)
• Interrupt_Handler29 (Obsolescent since Ada 2012)
• Interrupt_Priority30 (Obsolescent since Ada 2012)
• Linker_Options31
• List32
• Locking_Policy33
• Memory_Size34 (Obsolescent)
• No_Return35 (Ada 2005) (Obsolescent since Ada 2012)
12 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FControlled
13 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FConvention
14 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCPU
15 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FDefault_Storage_Pool
16 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FDetect_Blocking
17 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FDiscard_Names
18 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FDispatching_Domain
19 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FElaborate
20 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FElaborate_All
21 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FElaborate_Body
22 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FExport
23 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FImport
24 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FIndependent
25 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FIndependent_Component
26 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInline
27 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInspection_Point
28 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInterface
29 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInterrupt_Handler
30 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInterrupt_Priority
31 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FLinker_Options
32 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FList
33 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FLocking_Policy
34 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FMemory_Size
35 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FNo_Return
318
• Normalize_Scalars36
• Optimize37
39.2.3 P − R
• Pack38 (Obsolescent since Ada 2012)
• Page39
• Partition_Elaboration_Policy40 (Ada 2005)
• Preelaborable_Initialization41 (Ada 2005)
• Preelaborate42
• Priority43 (Obsolescent since Ada 2012)
• Priority_Specific_Dispatching44 (Ada 2005)
• Profile45 (Ada 2005)
• Pure46
• Queueing_Policy47
• Relative_Deadline48 (Ada 2005)
• Remote_Call_Interface49
• Remote_Types50
• Restrictions51
• Reviewable52
39.2.4 S − Z
• Shared53 (Obsolescent)
• Shared_Passive54
• Storage_Size55
• Storage_Unit56 (Obsolescent)
• Suppress57
36 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FNormalize_Scalars
37 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FOptimize
38 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPack
39 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPage
http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPartition_Elaboration_
40
Policy
http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPreelaborable_
41
Initialization
42 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPreelaborate
43 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPriority
http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPriority_Specific_
44
Dispatching
45 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FProfile
46 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPure
47 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FQueueing_Policy
48 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FRelative_Deadline
49 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FRemote_Call_Interface
50 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FRemote_Types
51 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FRestrictions
52 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FReviewable
53 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FShared
54 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FShared_Passive
55 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FStorage_Size
56 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FStorage_Unit
57 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FSuppress
319
Pragmas
• System_Name58 (Obsolescent)
• Task_Dispatching_Policy59
• Unchecked_Union60 (Ada 2005)
• Unsuppress61 (Ada 2005)
• Volatile62
• Volatile_Components63
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 adding64 specific aspects of other compilers:
GNAT
Implementation defined pragma65 of the GNAT66 compiler from AdaCore and FSF.
HP Ada
Implementation defined pragma67 of the HP Ada68 compiler (formerly known as "DEC
Ada").
ICC
Implementation-defined pragma69 of the Irvine ICC70 compiler.
PowerAda
Implementation defined pragma71 of OC Systems' PowerAda72 .
SPARCompiler
Implementation defined pragma73 of Sun's SPARCompiler Ada74 .http://
findarticles.com/p/articles/mi_m0EIN/is_1994_Nov_2/ai_15882197
39.3.1 A − C
• Abort_Defer75 (GNAT)
58 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FSystem_Name
59 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FTask_Dispatching_Policy
60 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FUnchecked_Union
61 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FUnsuppress
62 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FVolatile
63 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FVolatile_Components
64 http://en.wikibooks.org/w/index.php?title=Ada_Programming/Pragmas&action=edit
65 http://www.adacore.com/wp-content/files/auto_update/gnat-unw-docs/html/gnat_rm_2.html
66 http://en.wikibooks.org/wiki/Ada%20Programming%2FGNAT
67 http://h71000.www7.hp.com/commercial/ada/ada_lrm.pdf
68 http://h71000.www7.hp.com/commercial/ada/ada_index.html
69 "2.2 ICC-Defined Pragmas", ICC Ada Implementation Reference — ICC Ada Version 8.2.5 for i960MC
Targets, document version 2.11.4.http://www.irvine.com/support/general/
70 http://www.irvine.com/products.html
71 http://www.ocsystems.com/user_guide/powerada/html/powerada-106.html#HEADING106-0
72 http://www.ocsystems.com/prod_powerada.html
http://docs.sun.com/app/docs/doc/802-3641/6i7h8si5i?a=view#F.
73
Implementation-Dependent_Characteristi-2
74 http://docs.sun.com/app/docs/coll/15.4
75 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FAbort_Defer
320
• Ada_8376 (GNAT)
• Ada_9577 (GNAT)
• Ada_0578 (GNAT)
• Ada_200579 (GNAT)
• Ada_1280 (GNAT)
• Ada_201281 (GNAT)
• Annotate82 (GNAT)
• Assume_No_Invalid_Values83 (GNAT)
• Ast_Entry84 (GNAT, HP Ada)
• Bit_Pack85 (SPARCompiler)
• Built_In86 (SPARCompiler)
• Byte_Pack87 (SPARCompiler)
• C_Pass_By_Copy88 (GNAT)
• Call_Mechanism89 (ICC)
• Canonical_Streams90 (GNAT)
• Check91 (GNAT)
• Check_Name92 (GNAT)
• Check_Policy93 (GNAT)
• CM_Info94 (PowerAda)
• Comment95 (GNAT)
• Common_Object96 (GNAT, HP Ada)
• Compatible_Calls97 (ICC)
• Compile_Time_Error98 (GNAT)
• Compile_Time_Warning99 (GNAT)
• Complete_Representation100 (GNAT)
76 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FAda_83
77 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FAda_95
78 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FAda_05
79 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FAda_2005
80 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FAda_12
81 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FAda_2012
82 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FAnnotate
83 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FAssume_No_Invalid_Values
84 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FAst_Entry
85 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FBit_Pack
86 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FBuilt_In
87 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FByte_Pack
88 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FC_Pass_By_Copy
89 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCall_Mechanism
90 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCanonical_Streams
91 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCheck
92 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCheck_Name
93 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCheck_Policy
94 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCM_Info
95 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FComment
96 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCommon_Object
97 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCompatible_Calls
98 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCompile_Time_Error
99 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCompile_Time_Warning
100 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FComplete_Representation
321
Pragmas
• Complex_Representation101 (GNAT)
• Component_Alignment102 (GNAT, HP Ada)
• Compress103 (ICC)
• Constrain_Private104 (ICC)
• Convention_Identifier105 (GNAT)
• CPP_Class106 (GNAT)
• CPP_Constructor107 (GNAT)
• CPP_Virtual108 (GNAT)
• CPP_Vtable109 (GNAT)
39.3.2 D − H
• Data_Mechanism110 (ICC)
• Debug111 (GNAT)
• Debug_Policy112 (GNAT)
• Delete_Subprogram_Entry113 (ICC)
• Elaboration_Checks114 (GNAT)
• Eliminate115 (GNAT)
• Error116 (SPARCompiler)
• Export_Exception117 (GNAT, HP Ada)
• Export_Function118 (GNAT, HP Ada, SPARCompiler)
• Export_Mechanism119 (ICC)
• Export_Object120 (GNAT, HP Ada, SPARCompiler)
• Export_Procedure121 (GNAT, HP Ada, SPARCompiler)
• Export_Value122 (GNAT)
• Export_Valued_Procedure123 (GNAT, HP Ada)
• Extend_System124 (GNAT)
101 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FComplex_Representation
102 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FComponent_Alignment
103 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCompress
104 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FConstrain_Private
105 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FConvention_Identifier
106 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCPP_Class
107 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCPP_Constructor
108 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCPP_Virtual
109 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FCPP_Vtable
110 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FData_Mechanism
111 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FDebug
112 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FDebug_Policy
113 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FDelete_Subprogram_Entry
114 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FElaboration_Checks
115 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FEliminate
116 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FError
117 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FExport_Exception
118 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FExport_Function
119 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FExport_Mechanism
120 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FExport_Object
121 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FExport_Procedure
122 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FExport_Value
123 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FExport_Valued_Procedure
124 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FExtend_System
322
• Extensions_Allowed125 (GNAT)
• External126 (GNAT, SPARCompiler)
• External_Name127 (ICC, SPARCompiler)
• External_Name_Casing128 (GNAT)
• Fast_Math129 (GNAT)
• Favor_Top_Level130 (GNAT)
• Finalize_Storage_Only131 (GNAT)
• Float_Representation132 (GNAT, HP Ada)
• Foreign133 (ICC)
• Generic_Mechanism134 (ICC)
• Generic_Policy135 (SPARCompiler)
39.3.3 I − L
• i960_Intrinsic136 (ICC)
• Ident137 (GNAT, HP Ada)
• Images138 (PowerAda)
• Implemented139 , previously named 'Implemented_By_Entry' (GNAT)
• Implicit_Code140 (SPARCompiler)
• Implicit_Packing141 (GNAT)
• Import_Exception142 (GNAT, HP Ada)
• Import_Function143 (GNAT, HP Ada, SPARCompiler)
• Import_Mechanism144 (ICC)
• Import_Object145 (GNAT, HP Ada, SPARCompiler)
• Import_Procedure146 (GNAT, HP Ada, SPARCompiler)
• Import_Valued_Procedure147 (GNAT, HP Ada)
• Include148 (SPARCompiler)
125 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FExtensions_Allowed
126 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FExternal
127 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FExternal_Name
128 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FExternal_Name_Casing
129 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FFast_Math
130 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FFavor_Top_Level
131 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FFinalize_Storage_Only
132 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FFloat_Representation
133 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FForeign
134 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FGeneric_Mechanism
135 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FGeneric_Policy
136 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2Fi960_Intrinsic
137 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FIdent
138 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FImages
139 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FImplemented
140 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FImplicit_Code
141 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FImplicit_Packing
142 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FImport_Exception
143 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FImport_Function
144 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FImport_Mechanism
145 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FImport_Object
146 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FImport_Procedure
147 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FImport_Valued_Procedure
148 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInclude
323
Pragmas
• Initialize149 (SPARCompiler)
• Initialize_Scalars150 (GNAT)
• Inline_Always151 (GNAT)
• Inline_Generic152 (GNAT, HP Ada)
• Inline_Only153 (SPARCompiler)
• Instance_Policy154 (SPARCompiler)
• Interface_Constant155 (ICC)
• Interface_Information156 (PowerAda)
• Interface_Mechanism157 (ICC)
• Interface_Name158 (GNAT, HP Ada, ICC, SPARCompiler)
• Interrupt_State159 (GNAT)
• Invariant160 (GNAT)
• Keep_Names161 (GNAT)
• Label162 (ICC)
• License163 (GNAT)
• Link_With164 (GNAT, ICC, SPARCompiler)
• Linker_Alias165 (GNAT)
• Linker_Constructor166 (GNAT)
• Linker_Destructor167 (GNAT)
• Linker_Section168 (GNAT)
• Long_Float169 (GNAT: OpenVMS, HP Ada)
39.3.4 M − P
• Machine_Attribute170 (GNAT)
• Main171 (GNAT)
• Main_Storage172 (GNAT, HP Ada)
149 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInitialize
150 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInitialize_Scalars
151 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInline_Always
152 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInline_Generic
153 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInline_Only
154 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInstance_Policy
155 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInterface_Constant
156 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInterface_Information
157 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInterface_Mechanism
158 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInterface_Name
159 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInterrupt_State
160 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FInvariant
161 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FKeep_Names
162 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FLabel
163 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FLicense
164 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FLink_With
165 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FLinker_Alias
166 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FLinker_Constructor
167 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FLinker_Destructor
168 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FLinker_Section
169 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FLong_Float
170 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FMachine_Attribute
171 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FMain
172 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FMain_Storage
324
• No_Body173 (GNAT)
• No_Image174 (SPARCompiler)
• No_Strict_Aliasing175 (GNAT)
• No_Suppress176 (PowerAda)
• No_Reorder177 (ICC)
• No_Zero178 (ICC)
• Noinline179 (ICC)
• Non_Reentrant180 (SPARCompiler)
• Not_Elaborated181 (SPARCompiler)
• Not_Null182 (ICC)
• Obsolescent183 (GNAT)
• Optimize_Alignment184 (GNAT)
• Optimize_Code185 (SPARCompiler)
• Optimize_Options186 (ICC)
• Ordered187 (GNAT)
• Parameter_Mechanism188 (ICC)
• Passive189 (GNAT, HP Ada, SPARCompiler)
• Persistent_BSS190 (GNAT)
• Physical_Address191 (ICC)
• Polling192 (GNAT)
• Postcondition193 (GNAT)
• Precondition194 (GNAT)
• Preserve_Layout195 (PowerAda)
• Profile_Warnings196 (GNAT)
• Propagate_Exceptions197 (GNAT)
173 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FNo_Body
174 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FNo_Image
175 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FNo_Strict_Aliasing
176 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FNo_Suppress
177 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FNo_Reorder
178 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FNo_Zero
179 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FNoinline
180 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FNon_Reentrant
181 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FNot_Elaborated
182 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FNot_Null
183 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FObsolescent
184 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FOptimize_Alignment
185 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FOptimize_Code
186 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FOptimize_Options
187 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FOrdered
188 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FParameter_Mechanism
189 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPassive
190 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPersistent_BSS
191 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPhysical_Address
192 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPolling
193 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPostcondition
194 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPrecondition
195 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPreserve_Layout
196 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FProfile_Warnings
197 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPropagate_Exceptions
325
Pragmas
• Protect_Registers198 (ICC)
• Protected_Call199 (ICC)
• Protected_Return200 (ICC)
• Psect_Object201 (GNAT, HP Ada)
• Pure_Function202 (GNAT)
• Put203 (ICC)
• Put_Line204 (ICC)
39.3.5 R − S
• Reserve_Registers205 (ICC)
• Restriction_Warnings206 (GNAT)
• RTS_Interface207 (SPARCompiler)
• SCCS_ID208 (PowerAda)
• Share_Body209 (SPARCompiler)
• Share_Code210 (SPARCompiler)
• Share_Generic211 (GNAT, HP Ada)
• Shareable212 (ICC)
• Short_Circuit_And_Or213 (GNAT)
• Short_Descriptors214 (GNAT)
• Simple_Storage_Pool_Type215 (GNAT)
• Simple_Task216 (ICC)
• Source_File_Name217 (GNAT)
• Source_File_Name_Project218 (GNAT)
• Source_Reference219 (GNAT)
• Stack_Size220 (ICC)
• Static_Elaboration221 (ICC)
198 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FProtect_Registers
199 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FProtected_Call
200 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FProtected_Return
201 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPsect_Object
202 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPure_Function
203 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPut
204 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FPut_Line
205 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FReserve_Registers
206 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FRestriction_Warnings
207 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FRTS_Interface
208 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FSCCS_ID
209 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FShare_Body
210 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FShare_Code
211 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FShare_Generic
212 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FShareable
213 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FShort_Circuit_And_Or
214 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FShort_Descriptors
215 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FSimple_Storage_Pool_Type
216 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FSimple_Task
217 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FSource_File_Name
218 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FSource_File_Name_Project
219 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FSource_Reference
220 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FStack_Size
221 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FStatic_Elaboration
326
• Static_Elaboration_Desired222 (GNAT)
• Stream_Convert223 (GNAT)
• Style_Checks224 (GNAT)
• Subtitle225 (GNAT)
• Suppress_All226 (GNAT, HP Ada, PowerAda, SPARCompiler)
• Suppress_Elaboration_Checks227 (SPARCompiler)
• Suppress_Exception_Locations228 (GNAT)
• Suppress_Initialization229 (GNAT)
• System_Table230 (ICC)
39.3.6 T − Z
• Task_Attributes231 (SPARCompiler)
• Task_Info232 (GNAT)
• Task_Name233 (GNAT)
• Task_Storage234 (GNAT, HP Ada)
• Test_Case235 (GNAT)
• Thread_Body236 (GNAT)
• Thread_Local_Storage237 (GNAT)
• Time_Slice238 (GNAT, HP Ada, ICC)
• Time_Slice_Attributes239 (ICC)
• Title240 (GNAT, HP Ada)
• Unimplemented_Unit241 (GNAT)
• Universal_Aliasing242 (GNAT)
• Universal_Data243 (GNAT)
• Unmodified244 (GNAT)
222 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FStatic_Elaboration_Desired
223 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FStream_Convert
224 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FStyle_Checks
225 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FSubtitle
226 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FSuppress_All
http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FSuppress_Elaboration_
227
Checks
http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FSuppress_Exception_
228
Locations
229 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FSuppress_Initialization
230 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FSystem_Table
231 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FTask_Attributes
232 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FTask_Info
233 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FTask_Name
234 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FTask_Storage
235 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FTest_Case
236 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FThread_Body
237 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FThread_Local_Storage
238 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FTime_Slice
239 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FTime_Slice_Attributes
240 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FTitle
241 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FUnimplemented_Unit
242 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FUniversal_Aliasing
243 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FUniversal_Data
244 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FUnmodified
327
Pragmas
• Unreferenced245 (GNAT)
• Unreferenced_Objects246 (GNAT)
• Unreserve_All_Interrupts247 (GNAT)
• Unsigned_Literal248 (ICC)
• Use_VADS_Size249 (GNAT)
• Validity_Checks250 (GNAT)
• Warning251 (SPARCompiler)
• Warnings252 (GNAT, SPARCompiler)
• Weak_External253 (GNAT)
• Wide_Character_Encoding254 (GNAT)
39.4.1 Wikibook
• Ada Programming255
• Ada Programming/Aspects256
• Ada Programming/Attributes257
• Ada Programming/Keywords258
Ada 95
• 2.8 Pragmas259
• Annex L: (informative) Language-Defined Pragmas260
245 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FUnreferenced
246 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FUnreferenced_Objects
247 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FUnreserve_All_Interrupts
248 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FUnsigned_Literal
249 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FUse_VADS_Size
250 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FValidity_Checks
251 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FWarning
252 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FWarnings
253 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FWeak_External
254 http://en.wikibooks.org/wiki/Ada%20Programming%2FPragmas%2FWide_Character_Encoding
255 http://en.wikibooks.org/wiki/Ada%20Programming
256 http://en.wikibooks.org/wiki/Ada%20Programming%2FAspects
257 Chapter 38 on page 305
258 Chapter 35 on page 293
259 http://www.adaic.org/resources/add_content/standards/95lrm/ARM_HTML/RM-2-8.html
260 http://www.adaic.org/resources/add_content/standards/95lrm/ARM_HTML/RM-L.html
328
Ada 2005
• 2.8 Pragmas261
• Annex L: (informative) Language-Defined Pragmas262
Ada 2012
• 2.8 Pragmas263
• Annex L: (informative) Language-Defined Pragmas264
39.5 References
References
261 http://www.adaic.org/resources/add_content/standards/05rm/html/RM-2-2-8.html
262 http://www.adaic.org/resources/add_content/standards/05rm/html/RM-2-L.html
263 http://www.ada-auth.org/standards/12rm/html/RM-2-8.html
264 http://www.ada-auth.org/standards/12rm/html/RM-L.html
329
40 Libraries
The library which comes with Ada in general and GNAT1 in particular. Ada's built in
library is quite extensive and well structured. These chapters too are more reference like.
• Standard2
• Ada3
• Interfaces4
• System5
• GNAT6
Other libraries which are not part of the standard but freely available.
• Multi Purpose7
• Container Libraries8
• GUI Libraries9
• Distributed Objects10
• Database11
• Web Programming12
• Input/Output13
1 http://en.wikipedia.org/wiki/GNAT
2 Chapter 41 on page 333
3 Chapter 42 on page 337
4 Chapter 43 on page 349
5 Chapter 44 on page 351
6 Chapter 45 on page 353
7 Chapter 46 on page 357
8 Chapter 47 on page 359
9 Chapter 48 on page 361
10 Chapter 49 on page 363
11 Chapter 50 on page 365
12 Chapter 51 on page 371
13 Chapter 52 on page 373
331
Libraries
See also
40.3.1 Wikibook
• Ada Programming14
40.3.3 Resources
• A collection of Tools and Libraries15 maintained by the Ada Resource Association.
es:Programación en Ada/Unidades predefinidas16
14 http://en.wikibooks.org/wiki/Ada%20Programming
15 http://www.adaic.org/ada-resources/tools-libraries/
16 http://es.wikibooks.org/wiki/Programaci%F3n%20en%20Ada%2FUnidades%20predefinidas
332
41 Libraries: Standard
The Standard package is implicit. This means two things:
1. You do not need to with or use the package, in fact you cannot (see below). It's
always available (except where hidden by a homograph, RM 8.3 (8) ˆ{http://www.
adaic.org/resources/add_content/standards/05rm/html/RM-8-3.html} ).
2. Standard may contain constructs which are not quite legal Ada (like the definitions
of Character and Wide_Character).
A with clause mentioning Standard references a user-defined package Standard that
hides the predefined one. So do not do this. However any library unit hidden by a
homograph can be made visible again by qualifying its name with Standard, like e.g.
Standard.My_Unit.
41.1 Implementation
Implementation
Since the package Standard is very important for portability, here are some examples for
various compilers:
• The package Standard1 from ISO 86522 .
• The package Standard3 from GNAT4 .
• The package Standard5 from Rational Apex6 .
• The package Standard7 from ObjectAda8
• The Standard9 definitions for AppletMagic10
41.2 Portability
Portability
The only mandatory types in Standard are Boolean, Integer and its subtypes, Float,
Character, Wide_Character, Wide_Wide_Character, String, Wide_String, Wide_-
Wide_String, Duration. There is an implementation permission in RM A.1 (51) ˆ{http://
www.adaic.org/resources/add_content/standards/05rm/html/RM-A-1.html} that
there may be more integer and floating point types and an implementation advice RM
A.1 (52) ˆ{http://www.adaic.org/resources/add_content/standards/05rm/html/
1 http://en.wikibooks.org/wiki/%2FRM
2 http://en.wikipedia.org/wiki/ISO%208652
3 http://en.wikibooks.org/wiki/%2FGNAT
4 http://en.wikipedia.org/wiki/GNAT
5 http://en.wikibooks.org/wiki/%2FApex
6 http://www-306.ibm.com/software/awdtools/developer/ada
7 http://en.wikibooks.org/wiki/%2FObjectAda
8 http://www.aonix.com/objectada.html
9 http://en.wikibooks.org/wiki/%2FAppletMagic
10 http://www.sofcheck.com/products/adamagic.html#appletmagic
333
Libraries: Standard
RM-A-1.html} about the names to be chosen. There even is no requirement that those
additional types must have different sizes. So it is e.g. legal for an implementation to
provide two types Long_Integer and Long_Long_Integer which both have the same
range and size.
Note that the ranges and sizes of these types can be different in every platform (except of
course for Boolean and [[Wide_]Wide_]Character). There is an implementation requirement
that the size of type Integer is at least 16 bits, and that of Long_Integer at least 32
bits (if present) RM 3.5.4 (21..22) ˆ{http://www.adaic.org/resources/add_content/
standards/05rm/html/RM-3-5-4.html} . So if you want full portability of your types,
do not use types from Standard (except where you must, see below), rather define you own
types. A compiler will reject any type declaration whose range it cannot satisfy.
This means e.g. if you need a 64-bit type and find that with your current implemen-
tation Standard.Long_Long_Integer is such a type, when porting your program to
another implementation, this type may be shorter, but the compiler will not tell you
- and your program will most probably crash. However, when you define your own type like
then, when porting to an implementation that cannot satisfy this range, the compiler
will reject your program.
The type Integer is mandatory when you use [[wide] wide] strings or exponentiation x**i.
This is why some projects even define their own strings, but this means throwing out the
child with the bath tub. Using Integer with strings and exponentiation will normally not
lead to portability issues.
41.3.1 Wikibook
• Ada Programming11
• Ada Programming/Libraries#Predefined Language Libraries12
11 http://en.wikibooks.org/wiki/Ada%20Programming
12 Chapter 40.1 on page 331
334
41.3.3 Ada Quality and Style Guide
• 7.1.1 Obsolescent Features ˆ{http://www.adaic.org/resources/add_content/
docs/95style/html/sec_7/7-1-1.html} − Avoid using the package ASCII
• 7.2.1 Predefined Numeric Types ˆ{http://www.adaic.org/resources/add_
content/docs/95style/html/sec_7/7-2-1.html} − Avoid the predefined numeric
types
335
42 Libraries: Ada
The Ada package is only an anchor or namespace for Ada's standard library. Most
compilers will not allow you to add new packages to the Ada hierarchy and even if your
compiler allows it you should not do so since all package names starting with Ada. are
reserved for future extensions.
The following library units (packages and generic subprograms) are descendents of the
package Ada.
Ada 2005
This package is available since Ada 20051 .
42.1.1 A − C
• Ada.Assertions2 (Ada 2005)
• Ada.Asynchronous_Task_Control3
• Ada.Calendar4
• Ada.Calendar.Arithmetic5 (Ada 2005)
• Ada.Calendar.Formatting6 (Ada 2005)
• Ada.Calendar.Time_Zones7 (Ada 2005)
• Ada.Characters8
• Ada.Characters.Conversions9 (Ada 2005)
• Ada.Characters.Handling10
• Ada.Characters.Latin_111
• Ada.Command_Line12
• Ada.Complex_Text_IO13 (Ada 2005)
337
Libraries: Ada
42.1.2 D − F
• Ada.Decimal29
• Ada.Direct_IO30
• Ada.Directories31 (Ada 2005)
• Ada.Directories.Information32 (Ada 2005)
• Ada.Dispatching33 (Ada 2005)
14 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers.Doubly_
15
Linked_Lists
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers.Generic_
16
Array_Sort
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers.Generic_
17
Constrained_Array_Sort
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers.Hashed_
18
Maps
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers.Hashed_
19
Sets
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers.
20
Indefinite_Doubly_Linked_Lists
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers.
21
Indefinite_Hashed_Maps
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers.
22
Indefinite_Hashed_Sets
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers.
23
Indefinite_Ordered_Maps
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers.
24
Indefinite_Ordered_Sets
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers.
25
Indefinite_Vectors
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers.Ordered_
26
Maps
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers.Ordered_
27
Sets
28 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers.Vectors
29 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Decimal
30 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Direct_IO
31 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Directories
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Directories.
32
Information
33 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Dispatching
338
• Ada.Dispatching.EDF34 (Ada 2005)
• Ada.Dispatching.Round_Robin35 (Ada 2005)
• Ada.Dynamic_Priorities36
• Ada.Environment_Variables37 (Ada 2005)
• Ada.Exceptions38
• Ada.Execution_Time39 (Ada 2005)
• Ada.Execution_Time.Timers40 (Ada 2005)
• Ada.Execution_Time.Group_Budgets41 (Ada 2005)
• Ada.Finalization42
• Ada.Float_Text_IO43
• Ada.Float_Wide_Text_IO44
• Ada.Float_Wide_Wide_Text_IO45 (Ada 2005)
42.1.3 G − R
• Ada.Integer_Text_IO46
• Ada.Integer_Wide_Text_IO47
• Ada.Integer_Wide_Wide_Text_IO48 (Ada 2005)
• Ada.Interrupts49
• Ada.Interrupts.Names50
• Ada.IO_Exceptions51
• Ada.Numerics52
• Ada.Numerics.Complex_Arrays53 (Ada 2005)
• Ada.Numerics.Complex_Elementary_Functions54
34 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Dispatching.EDF
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Dispatching.Round_
35
Robin
36 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Dynamic_Priorities
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Environment_
37
Variables
38 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Exceptions
39 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Execution_Time
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Execution_Time.
40
Timers
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Execution_Time.
41
Group_Budgets
42 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Finalization
43 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Float_Text_IO
44 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Float_Wide_Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Float_Wide_Wide_
45
Text_IO
46 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Integer_Text_IO
47 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Integer_Wide_Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Integer_Wide_Wide_
48
Text_IO
49 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Interrupts
50 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Interrupts.Names
51 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.IO_Exceptions
52 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Complex_
53
Arrays
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Complex_
54
Elementary_Functions
339
Libraries: Ada
• Ada.Numerics.Complex_Types55
• Ada.Numerics.Discrete_Random56
• Ada.Numerics.Elementary_Functions57
• Ada.Numerics.Float_Random58
• Ada.Numerics.Generic_Complex_Arrays59 (Ada 2005)
• Ada.Numerics.Generic_Complex_Elementary_Functions60
• Ada.Numerics.Generic_Complex_Types61
• Ada.Numerics.Generic_Elementary_Functions62
• Ada.Numerics.Generic_Real_Arrays63 (Ada 2005)
• Ada.Numerics.Real_Arrays64 (Ada 2005)
42.1.4 R − S
• Ada.Real_Time65
• Ada.Real_Time.Timing_Events66 (Ada 2005)
• Ada.Sequential_IO67
• Ada.Storage_IO68
• Ada.Streams69
• Ada.Streams.Stream_IO70
• Ada.Strings71
• Ada.Strings.Bounded72
• Ada.Strings.Bounded.Hash73 (Ada 2005 generic function)
• Ada.Strings.Fixed74
• Ada.Strings.Fixed.Hash75 (Ada 2005 generic function)
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Complex_
55
Types
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Discrete_
56
Random
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Elementary_
57
Functions
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Float_
58
Random
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Generic_
59
Complex_Arrays
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Generic_
60
Complex_Elementary_Functions
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Generic_
61
Complex_Types
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Generic_
62
Elementary_Functions
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Generic_
63
Real_Arrays
64 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Real_Arrays
65 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Real_Time
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Real_Time.Timing_
66
Events
67 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Sequential_IO
68 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Storage_IO
69 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Streams
70 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Streams.Stream_IO
71 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings
72 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Bounded
73 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Bounded.Hash
74 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Fixed
75 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Fixed.Hash
340
• Ada.Strings.Hash76 (Ada 2005 generic function)
• Ada.Strings.Maps77
• Ada.Strings.Maps.Constants78
• Ada.Strings.Unbounded79
• Ada.Strings.Unbounded.Hash80 (Ada 2005 generic function)
• Ada.Strings.Wide_Bounded81
• Ada.Strings.Wide_Bounded.Wide_Hash82 (Ada 2005 generic function)
• Ada.Strings.Wide_Fixed83
• Ada.Strings.Wide_Fixed.Wide_Hash84 (Ada 2005 generic function)
• Ada.Strings.Wide_Hash85 (Ada 2005 generic function)
• Ada.Strings.Wide_Maps86
• Ada.Strings.Wide_Maps.Wide_Constants87
• Ada.Strings.Wide_Unbounded88
• Ada.Strings.Wide_Unbounded.Wide_Hash89 (Ada 2005 generic function)
• Ada.Strings.Wide_Wide_Bounded90 (Ada 2005)
• Ada.Strings.Wide_Wide_Bounded.Wide_Wide_Hash91 (Ada 2005 generic function)
• Ada.Strings.Wide_Wide_Fixed92 (Ada 2005)
• Ada.Strings.Wide_Wide_Fixed.Wide_Wide_Hash93 (Ada 2005 generic function)
• Ada.Strings.Wide_Wide_Hash94 (Ada 2005 generic function)
• Ada.Strings.Wide_Wide_Maps95 (Ada 2005)
• Ada.Strings.Wide_Wide_Maps.Wide_Wide_Constants96 (Ada 2005)
76 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Hash
77 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Maps
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Maps.
78
Constants
79 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Unbounded
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Unbounded.
80
Hash
81 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Bounded
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Bounded.
82
Wide_Hash
83 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Fixed
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Fixed.
84
Wide_Hash
85 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Hash
86 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Maps
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Maps.
87
Wide_Constants
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_
88
Unbounded
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_
89
Unbounded.Wide_Hash
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Wide_
90
Bounded
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Wide_
91
Bounded.Wide_Wide_Hash
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Wide_
92
Fixed
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Wide_
93
Fixed.Wide_Wide_Hash
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Wide_
94
Hash
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Wide_
95
Maps
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Wide_
96
Maps.Wide_Wide_Constants
341
Libraries: Ada
42.1.5 T − U
• Ada.Tags100
• Ada.Tags.Generic_Dispatching_Constructor101 (generic function)
• Ada.Task_Attributes102
• Ada.Task_Identification103
• Ada.Task_Termination104 (Ada 2005)
• Ada.Text_IO105
• Ada.Text_IO.Bounded_IO106 (Ada 2005)
• Ada.Text_IO.Complex_IO107
• Ada.Text_IO.Decimal_IO108 (Nested package of Ada.Text_IO )
• Ada.Text_IO.Editing109
• Ada.Text_IO.Enumeration_IO110 (Nested package of Ada.Text_IO111 )
• Ada.Text_IO.Fixed_IO112 (Nested package of Ada.Text_IO )
• Ada.Text_IO.Float_IO113 (Nested package of Ada.Text_IO )
• Ada.Text_IO.Integer_IO114 (Nested package of Ada.Text_IO )
• Ada.Text_IO.Modular_IO115 (Nested package of Ada.Text_IO )
• Ada.Text_IO.Text_Streams116
• Ada.Text_IO.Unbounded_IO117 (Ada 2005)
• Ada.Unchecked_Conversion118 (generic function)
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Wide_
97
Unbounded
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Wide_
98
Unbounded.Wide_Wide_Hash
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Synchronous_Task_
99
Control
100 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Tags
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Tags.Generic_
101
Dispatching_Constructor
102 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Task_Attributes
103 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Task_Identification
104 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Task_Termination
105 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO
106 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Bounded_IO
107 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Complex_IO
108 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Decimal_IO
109 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Editing
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Enumeration_
110
IO
111 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO
112 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Fixed_IO
113 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Float_IO
114 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Integer_IO
115 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Modular_IO
116 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Text_Streams
117 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.Unbounded_IO
118 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Unchecked_Conversion
342
• Ada.Unchecked_Deallocation119 (generic procedure)
42.1.6 W − Z
• Ada.Wide_Characters120 (Ada 2005)
• Ada.Wide_Text_IO121
• Ada.Wide_Text_IO.Bounded_IO122 (Ada 2005)
• Ada.Wide_Text_IO.Complex_IO123
• Ada.Wide_Text_IO.Decimal_IO124 (Nested package of Ada.Wide_Text_IO )
• Ada.Wide_Text_IO.Editing125
• Ada.Wide_Text_IO.Enumeration_IO126 (Nested package of Ada.Wide_Text_IO )
• Ada.Wide_Text_IO.Fixed_IO127 (Nested package of Ada.Wide_Text_IO )
• Ada.Wide_Text_IO.Float_IO128 (Nested package of Ada.Wide_Text_IO )
• Ada.Wide_Text_IO.Integer_IO129 (Nested package of Ada.Wide_Text_IO )
• Ada.Wide_Text_IO.Modular_IO130 (Nested package of Ada.Wide_Text_IO )
• Ada.Wide_Text_IO.Text_Streams131
• Ada.Wide_Text_IO.Unbounded_IO132 (Ada 2005)
• Ada.Wide_Wide_Characters133 (Ada 2005)
• Ada.Wide_Wide_Text_IO134 (Ada 2005)
• Ada.Wide_Wide_Text_IO.Bounded_IO135 (Ada 2005)
• Ada.Wide_Wide_Text_IO.Complex_IO136 (Ada 2005)
• Ada.Wide_Wide_Text_IO.Decimal_IO137 (Nested package of Ada.Wide_Wide_-
Text_IO )
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Unchecked_
119
Deallocation
120 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Characters
121 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Text_IO.
122
Bounded_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Text_IO.
123
Complex_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Text_IO.
124
Decimal_IO
125 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Text_IO.Editing
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Text_IO.
126
Enumeration_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Text_IO.Fixed_
127
IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Text_IO.Float_
128
IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Text_IO.
129
Integer_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Text_IO.
130
Modular_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Text_IO.Text_
131
Streams
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Text_IO.
132
Unbounded_IO
133 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Wide_Characters
134 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Wide_Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Wide_Text_IO.
135
Bounded_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Wide_Text_IO.
136
Complex_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Wide_Text_IO.
137
Decimal_IO
343
Libraries: Ada
The Reference Manual allows compiler vendors to add extensions to the Standard Libraries.
However, these extensions cannot be directly childs of the package Ada, only grandchilds
-- for example Ada.Characters.Latin_9 .
Currently, only the implementation defined library units of the GNAT146 compiler are
listed here. You can help Wikibooks by adding147 implementation dependent packages
of other compilers:
GNAT
Extended package implemented by GNAT148 .
ObjectAda
Extended package implemented by ObjectAda.
APEX
Extended package implemented by IBM/Rational APEX.
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Wide_Text_IO.
138
Editing
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Wide_Text_IO.
139
Enumeration_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Wide_Text_IO.
140
Fixed_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Wide_Text_IO.
141
Float_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Wide_Text_IO.
142
Integer_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Wide_Text_IO.
143
Modular_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Wide_Text_IO.
144
Text_Streams
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Wide_Text_IO.
145
Unbounded_IO
146 http://en.wikipedia.org/wiki/GNAT
147 http://en.wikibooks.org/w/index.php?title=Ada_Programming/Libraries/Ada&action=edit
148 http://gcc.gnu.org/onlinedocs/gnat_rm/The-GNAT-Library.html
344
42.2.1 A − K
• Ada.Characters.Latin_9149 (GNAT)
• Ada.Characters.Wide_Latin_1150 (GNAT)
• Ada.Characters.Wide_Latin_9151 (GNAT)
• Ada.Characters.Wide_Wide_Latin_1152 (GNAT)
• Ada.Characters.Wide_Wide_Latin_9153 (GNAT)
• Ada.Command_Line.Environment154 (GNAT)
• Ada.Command_Line.Remove155 (GNAT)
• Ada.Direct_IO.C_Streams156 (GNAT)
• Ada.Exceptions.Is_Null_Occurrence157 (GNAT child function)
• Ada.Exceptions.Traceback158 (GNAT)
42.2.2 L − Q
• Ada.Long_Float_Text_IO159 (GNAT)
• Ada.Long_Float_Wide_Text_IO160 (GNAT)
• Ada.Long_Integer_Text_IO161 (GNAT)
• Ada.Long_Integer_Wide_Text_IO162 (GNAT)
• Ada.Long_Long_Float_Text_IO163 (GNAT)
• Ada.Long_Long_Float_Wide_Text_IO164 (GNAT)
• Ada.Long_Long_Integer_Text_IO165 (GNAT)
• Ada.Long_Long_Integer_Wide_Text_IO166 (GNAT)
• Ada.Numerics.Long_Complex_Elementary_Functions167 (GNAT)
149 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Characters.Latin_9
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Characters.Wide_
150
Latin_1
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Characters.Wide_
151
Latin_9
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Characters.Wide_
152
Wide_Latin_1
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Characters.Wide_
153
Wide_Latin_9
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Command_Line.
154
Environment
155 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Command_Line.Remove
156 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Direct_IO.C_Streams
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Exceptions.Is_Null_
157
Occurrence
158 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Exceptions.Traceback
159 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Long_Float_Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Long_Float_Wide_
160
Text_IO
161 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Long_Integer_Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Long_Integer_Wide_
162
Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Long_Long_Float_
163
Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Long_Long_Float_
164
Wide_Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Long_Long_Integer_
165
Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Long_Long_Integer_
166
Wide_Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Long_
167
Complex_Elementary_Functions
345
Libraries: Ada
• Ada.Numerics.Long_Complex_Types168 (GNAT)
• Ada.Numerics.Long_Elementary_Functions169 (GNAT)
• Ada.Numerics.Long_Long_Complex_Elementary_Functions170 (GNAT)
• Ada.Numerics.Long_Long_Complex_Types171 (GNAT)
• Ada.Numerics.Long_Long_Elementary_Functions172 (GNAT)
• Ada.Numerics.Short_Complex_Elementary_Functions173 (GNAT)
• Ada.Numerics.Short_Complex_Types174 (GNAT)
• Ada.Numerics.Short_Elementary_Functions175 (GNAT)
42.2.3 R − Z
• Ada.Sequential_IO.C_Streams176 (GNAT)
• Ada.Short_Float_Text_IO177 (GNAT)
• Ada.Short_Float_Wide_Text_IO178 (GNAT)
• Ada.Short_Integer_Text_IO179 (GNAT)
• Ada.Short_Integer_Wide_Text_IO180 (GNAT)
• Ada.Short_Short_Integer_Text_IO181 (GNAT)
• Ada.Short_Short_Integer_Wide_Text_IO182 (GNAT)
• Ada.Streams.Stream_IO.C_Streams183 (GNAT)
• Ada.Strings.Unbounded.Text_IO184 (GNAT)
• Ada.Strings.Wide_Unbounded.Wide_Text_IO185 (GNAT)
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Long_
168
Complex_Types
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Long_
169
Elementary_Functions
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Long_Long_
170
Complex_Elementary_Functions
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Long_Long_
171
Complex_Types
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Long_Long_
172
Elementary_Functions
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Short_
173
Complex_Elementary_Functions
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Short_
174
Complex_Types
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Numerics.Short_
175
Elementary_Functions
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Sequential_IO.C_
176
Streams
177 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Short_Float_Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Short_Float_Wide_
178
Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Short_Integer_Text_
179
IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Short_Integer_Wide_
180
Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Short_Short_Integer_
181
Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Short_Short_Integer_
182
Wide_Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Streams.Stream_IO.C_
183
Streams
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Unbounded.
184
Text_IO
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_
185
Unbounded.Wide_Text_IO
346
• Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO186 (GNAT)
• Ada.Text_IO.C_Streams187 (GNAT)
• Ada.Wide_Text_IO.C_Streams188 (GNAT)
• Ada.Wide_Wide_Text_IO.C_Streams189 (GNAT)
42.3.1 Wikibook
• Ada Programming190
• Ada Programming/Libraries191
• Ada Programming/Libraries/Standard192
• Ada Programming/Libraries/System193
• Ada Programming/Libraries/Interfaces194
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Strings.Wide_Wide_
186
Unbounded.Wide_Wide_Text_IO
187 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Text_IO.C_Streams
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Text_IO.C_
188
Streams
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Wide_Wide_Text_IO.C_
189
Streams
190 http://en.wikibooks.org/wiki/Ada%20Programming
191 Chapter 40 on page 331
192 Chapter 41 on page 333
193 Chapter 44 on page 351
194 Chapter 43 on page 349
347
43 Libraries: Interfaces
The Interfaces package helps in interfacing with other programming languages. Ada is
one of the few languages where interfacing with other languages is part of the language
standard. The language standard defines the interfaces for C1 , Cobol2 and Fortran3 . Of
course any implementation might define further interfaces — GNAT4 for example defines
an interface to C++5 .
Interfacing with other languages is actually provided by pragma , pragma and pragma
• Interfaces.C6
• Interfaces.C.Extensions7 (GNAT)
• Interfaces.C.Pointers8
• Interfaces.C.Streams9 (GNAT)
• Interfaces.C.Strings10
• Interfaces.CPP11 (GNAT)
• Interfaces.COBOL12
• Interfaces.Fortran13
• Interfaces.OS2Lib14 (GNAT, OS/2)
• Interfaces.OS2Lib.Errors15 (GNAT, OS/2)
• Interfaces.OS2Lib.Synchronization16 (GNAT, OS/2)
• Interfaces.OS2Lib.Threads17 (GNAT, OS/2)
• Interfaces.Packed_Decimal18 (GNAT)
1 http://en.wikibooks.org/wiki/C%20Programming
2 http://en.wikibooks.org/wiki/COBOL
3 http://en.wikibooks.org/wiki/Programming%3AFortran
4 http://en.wikibooks.org/wiki/Ada%20Programming%2FGNAT
5 http://en.wikibooks.org/wiki/C%2B%2B%20Programming
6 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.C
7 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.C.Extensions
8 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.C.Pointers
9 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.C.Streams
10 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.C.Strings
11 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.CPP
12 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.COBOL
13 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.Fortran
14 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.OS2Lib
15 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.OS2Lib.Errors
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.OS2Lib.
16
Synchronization
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.OS2Lib.
17
Threads
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.Packed_
18
Decimal
349
Libraries: Interfaces
43.2.1 Wikibook
• Ada Programming21
• Ada Programming/Libraries22
• Ada Programming/Libraries/Standard23
• Ada Programming/Libraries/Ada24
• Ada Programming/Libraries/System25
Ada 2005
• Annex B Interface to Other Languages ˆ{http://www.adaic.org/resources/add_
content/standards/05rm/html/RM-B.html}
• B.2 The Package Interfaces ˆ{http://www.adaic.org/resources/add_content/
standards/05rm/html/RM-B-2.html}
19 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.VxWorks
20 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FInterfaces.VxWorks.IO
21 http://en.wikibooks.org/wiki/Ada%20Programming
22 Chapter 40 on page 331
23 Chapter 41 on page 333
24 Chapter 42 on page 337
25 Chapter 44 on page 351
350
44 Libraries: System
351
45 Libraries: GNAT
The GNAT package hierarchy defines several units for general purpose programming
provided by the GNAT compiler. It is distributed along with the compiler and uses the
same license.
GNAT-4-ObjectAda1 is a project for porting the GNAT library to the ObjectAda compiler.
• GNAT.Array_Split2
• GNAT.AWK3
• GNAT.Bounded_Buffers4
• GNAT.Bounded_Mailboxes5
• GNAT.Bubble_Sort6
• GNAT.Bubble_Sort_A7
• GNAT.Bubble_Sort_G8
• GNAT.Calendar9
• GNAT.Calendar.Time_IO10
• GNAT.Case_Util11
• GNAT.CGI12
• GNAT.CGI.Cookie13
• GNAT.CGI.Debug14
• GNAT.Command_Line15
• GNAT.Compiler_Version16
• GNAT.CRC3217
• GNAT.Ctrl_C18
1 http://sourceforge.net/projects/gnat4oa
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Array_Split
3 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.AWK
4 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Bounded_Buffers
5 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Bounded_Mailboxes
6 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Bubble_Sort
7 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Bubble_Sort_A
8 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Bubble_Sort_G
9 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Calendar
10 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Calendar.Time_IO
11 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Case_Util
12 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.CGI
13 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.CGI.Cookie
14 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.CGI.Debug
15 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Command_Line
16 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Compiler_Version
17 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.CRC32
18 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Ctrl_C
353
Libraries: GNAT
• GNAT.Current_Exception19
• GNAT.Debug_Pools20
• GNAT.Debug_Utilities21
• GNAT.Directory_Operations22
• GNAT.Directory_Operations.Iteration23
• GNAT.Dynamic_HTables24
• GNAT.Dynamic_Tables25
• GNAT.Exception_Actions26
• GNAT.Exceptions27
• GNAT.Exception_Traces28
• GNAT.Expect29
• GNAT.Float_Control30
• GNAT.Heap_Sort31
• GNAT.Heap_Sort_A32
• GNAT.Heap_Sort_G33
• GNAT.HTable34
• GNAT.IO35
• GNAT.IO_Aux36
• GNAT.Lock_Files37
• GNAT.MD538
• GNAT.Memory_Dump39
• GNAT.Most_Recent_Exception40
• GNAT.OS_Lib41
• GNAT.Perfect_Hash_Generators42
19 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Current_Exception
20 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Debug_Pools
21 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Debug_Utilities
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Directory_
22
Operations
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Directory_
23
Operations.Iteration
24 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Dynamic_HTables
25 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Dynamic_Tables
26 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Exception_Actions
27 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Exceptions
28 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Exception_Traces
29 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Expect
30 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Float_Control
31 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Heap_Sort
32 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Heap_Sort_A
33 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Heap_Sort_G
34 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.HTable
35 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.IO
36 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.IO_Aux
37 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Lock_Files
38 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.MD5
39 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Memory_Dump
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Most_Recent_
40
Exception
41 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.OS_Lib
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Perfect_Hash_
42
Generators
354
• GNAT.Regexp43
• GNAT.Registry44
• GNAT.Regpat45
• GNAT.Secondary_Stack_Info46
• GNAT.Semaphores47
• GNAT.Signals48
• GNAT.Sockets49 (GNAT.Sockets examples50 )
• GNAT.Sockets.Constants51
• GNAT.Sockets.Linker_Options52
• GNAT.Sockets.Thin53
• GNAT.Source_Info54
• GNAT.Spelling_Checker55
• GNAT.Spitbol56
• GNAT.Spitbol.Patterns57
• GNAT.Spitbol.Table_Boolean new58
• GNAT.Spitbol.Table_Integer59
• GNAT.Spitbol.Table_VString new60
• GNAT.Strings61
• GNAT.String_Split62
• GNAT.Table63
• GNAT.Task_Lock64
• GNAT.Threads65
• GNAT.Traceback66
43 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Regexp
44 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Registry
45 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Regpat
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Secondary_Stack_
46
Info
47 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Semaphores
48 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Signals
49 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Sockets
50 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Sockets_examples
51 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Sockets.Constants
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Sockets.Linker_
52
Options
53 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Sockets.Thin
54 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Source_Info
55 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Spelling_Checker
56 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Spitbol
57 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Spitbol.Patterns
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Spitbol.Table_
58
Boolean%20new
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Spitbol.Table_
59
Integer
http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Spitbol.Table_
60
VString%20new
61 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Strings
62 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.String_Split
63 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Table
64 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Task_Lock
65 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Threads
66 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Traceback
355
Libraries: GNAT
• GNAT.Traceback.Symbolic67
• GNAT.Wide_String_Split68
45.2.2 Wikibook
• Ada Programming70
• Ada Programming/Libraries71
67 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Traceback.Symbolic
68 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGNAT.Wide_String_Split
69 http://gcc.gnu.org/onlinedocs/gnat_rm/The-GNAT-Library.html
70 http://en.wikibooks.org/wiki/Ada%20Programming
71 Chapter 40 on page 331
356
46 Libraries: Multi-Purpose
AdaCL, Ada Class Library1
Filtering of text files, string tools, process control, command line parsing, CGI, garbage
collector, components.
Matreshka2
Core components for information system development: Unicode support (case conver-
sions and folding, collation, normalization); regular expression engine; XML processor;
FastCGI, SQL database access.
paraffin3
"A suite of Ada 2005 generics to facilitate iterative and recursive parallelism".4 Features
include load-balancing and monitoring of stacks.
46.1.1 Wikibook
• Ada Programming6
• Ada Programming/Libraries7
46.1.3 References
1 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FMultiPurpose%2FAdaCL
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FMultiPurpose%2FMatreshka
3 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FMultiPurpose%2FParaffin
4 Iterative and recursive parallelism generics for Ada 2005 5 . . Retrieved 2012-08-28
6 http://en.wikibooks.org/wiki/Ada%20Programming
7 Chapter 40 on page 331
357
47 Libraries: Container
The following Libraries help you store and manage objects inside container classes:
Booch Components1
the most complete of all container class libraries (at least when used with AdaCL, Ada
Class Library2 ).
AdaCL, Ada Class Library3
A Booch Components4 extension pack for storing indefinite objects.
Charles5
Build on the C++ STL and therefore very easy to learn for C++ developers.
AI3026
Proof of concept for Ada.Containers7
Ada.Containers8
This language feature is only available in Ada 2005
Stephe's Ada Library9
dynamic arrays, lists, trees
47.1.1 Wikibook
• Ada Programming10
• Ada Programming/Libraries11
1 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FContainer%2FBooch
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FMultiPurpose%2FAdaCL
3 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FMultiPurpose%2FAdaCL
4 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FContainer%2FBooch
5 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FContainer%2FCharles
6 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FContainer%2FAI302
7 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers
8 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FAda.Containers
9 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FSAL
10 http://en.wikibooks.org/wiki/Ada%20Programming
11 Chapter 40 on page 331
359
48 Libraries: GUI
The following libraries can be used to make Graphical User Interfaces:
CLAW1
Commercial GUI toolkit for Windows. Introductory Edition2 is distributed under
GMGPL3 .
GtkAda4
Binding to the popular GTK+ toolkit.
GWindows5
RAD GUI Development Framework for Windows.
Qt4Ada6
An Ada2005 binding to Qt4. Under CeCILL license V2.
QtAda7
An Ada2005 binding to the Qt libraries and associated tools. Under GPL and GMGPL8
(commercially supported) licenses.
libAgar9
Ada bindings for the libagar10 OpenGL GUI library (BSD license).
TASH11
TclAdaSHell, An Ada binding to Tcl/Tk. GPL with "Linking Exception".
48.1.1 Wikibook
• Ada Programming12
• Ada Programming/Libraries13
1 http://www.rrsoftware.com/html/prodinf/claw/claw.htm
2 http://www.adapower.com/adapower1/claw/
3 http://en.wikipedia.org/wiki/GMGPL
4 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGUI%2FGtkAda
5 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGUI%2FGWindows
6 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGUI%2FQt4Ada
7 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGUI%2FQtAda
8 http://en.wikipedia.org/wiki/GMGPL
9 http://wiki.libagar.org/wiki/Ada_bindings
10 http://libagar.org/
11 http://sourceforge.net/projects/tcladashell/
12 http://en.wikibooks.org/wiki/Ada%20Programming
13 Chapter 40 on page 331
361
Libraries: GUI
14 http://www.adapower.com/index.php?Command=Class&ClassID=AdaGUI&Title=Ada+GUI
http://www.adapower.com/index.php?Command=Class&ClassID=GUIExamples&Title=GUI+
15
Examples
362
49 Libraries: Distributed Systems
The following Libraries help you in Distributed programming:
GLADE1
A full implementation of the Ada Annex E: Distributed Systems2
PolyORB3
A CORBA4 and Annex E: Distributed Systems5 implementation.
49.1.1 Wikibook
• Ada Programming6
• Ada Programming/Libraries7
• Programming:CORBA8
1 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FDistributed%2FGLADE
2 http://www.adaic.org/standards/95lrm/html/RM-E.html
3 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FDistributed%2FPolyORB
4 http://en.wikibooks.org/wiki/Programming%3ACORBA
5 http://www.adaic.org/standards/95lrm/html/RM-E.html
6 http://en.wikibooks.org/wiki/Ada%20Programming
7 Chapter 40 on page 331
8 http://en.wikibooks.org/wiki/Programming%3ACORBA
363
50 Libraries: Databases
The following libraries help you in Database programming:
365
366
Li- Li- Inter- MySQL ODBC Ora- Post- SQLite Sybase Other Bi- Notes
brary cense base cle greSQL 3 database nary
Fire- pack-
bird ages
APQ1 GMGPL — Yes Yes — Yes — Yes — De- Thread-
bian2 safe
Libraries: Databases
connec-
tion
pools
GNADE GMGPL — 3.x, Yes — Yes Yes — — De- Em-
(GNu 4.x bian4 bedded
Ada SQL
Database prepro-
Envi- cessor
ron-
ment)3
gnadelite5? ? ? ? ? ? Yes ? ? ?
1 http://framework.kow.com.br
2 http://packages.qa.debian.org/a/apq.html
3 http://gnade.sourceforge.net
4 http://packages.qa.debian.org/g/gnade.html
5 http://repo.or.cz/w/gnadelite.git
GNAT- GPL/G- — — — — Yes Yes — — ? gnatcoll_-
COLL MGPL db2ada
(database gener-
inter- ates
face thick
mod- Ada
ule)6 bind-
ings to
a spec-
ified
database
schema.
Re-
quires
Ada
2005.
GWin- ? ? ? Yes ? ? ? ? ? ? Win-
dows7 dows
only?
Ma- BSD Yes Yes — Yes Yes Yes — — Open-
treshka SUSE9 ,
SQL8 Fe-
dora10
http://www.adacore.com/wp-content/files/auto_update/gnatcoll-docs/gnatcoll.html#
6
Database-interface
7 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FDatabase%2FGWindows
8 http://adaforge.qtada.com/cgi-bin/tracker.fcgi/matreshka/wiki
9 http://www.opensuse.org
367
10 http://www.fedoraproject.org
368
ODBC11 GPL ? ? Yes ? ? ? ? ? none Win-
dows
only.
De-
pends
on
Libraries: Databases
Win32Ada.
Very
simple.
QtAda GPL/G- Yes Yes Yes Yes Yes Yes Yes IBM Mi- Bind-
(QtSql MGPL DB/2, crosoft ing to
mod- SQLite2 Win- Qt: re-
ule)12 dows quires
C++
11 http://pobry.blogspot.fr/p/ada-contributions.html
12 http://www.qtada.com/
Sim- GMGPL — — Yes — — Yes — — Fe- SQLite
ple dora, bind-
Compo- Debian ings
nents are in-
for tended
Ada13 for
static
linking
with
the
SQLite3
amal-
gation.
ODBC
bind-
ings
support
32- and
64-bit
plat-
forms
SOCI- Boost — Yes — Yes Yes — — — ? Re-
Ada14 quires
C++.
SQLite3- Public — — — — — Yes — — ?
Ada15 domain
13 http://www.dmitry-kazakov.de/ada/components.htm#SQLite
14 http://www.inspirel.com/soci-ada/
369
15 http://coreland.ath.cx/code/sqlite3-ada
51 Libraries: Web
The following libraries help you in Internet or Web programming:
AdaCL, Ada Class Library1
Powerful CGI implementation.
XML/Ada2
XML and Unicode support.
AWS3
A full-featured Web-Server.
Matreshka4
FastCGI, XML, Unicode and localization support.
51.1.1 Wikibook
• Ada Programming5
• Ada Programming/Libraries6
1 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FMultiPurpose%2FAdaCL
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FIO%2FXML%2FAda
3 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FWeb%2FAWS
4 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FMultiPurpose%2FMatreshka
5 http://en.wikibooks.org/wiki/Ada%20Programming
6 Chapter 40 on page 331
371
52 Libraries: Input Output
The following libraries help you when doing input/output1 :
AdaCL, Ada Class Library2
A multipurpose library featuring filtering of text files, string I/O, command line parsing,
etc.
XML/Ada3
XML and Unicode support.
Matreshka4
SAX-style XML reader and writer. Supports XML1.0 (Fifth Edition), XML1.1 (Second
Edition), Namespaces in XML and XML Base Specifications. Strings, files and sockets
can be used as input source in both blocking and non-blocking modes. Full Unicode
support and many text codecs is provided also.
52.1.1 Wikibook
• Ada Programming5
• Ada Programming/Libraries6
373
53 Platform Support
Ada is known to be very portable, but there is sometimes a necessity of using a specific
platform feature. For that matter, there are some non-standard libraries.
• Linux1
• Windows2
• POSIX systems3
• Virtual machines4
• Java5
• .NET6
53.1.1 Wikibook
• Ada Programming7
375
54 Platform: Linux
The following libraries help you when you target the Linux Platform.
Florist1
POSIX.5 binding. It will let you perform Linux system calls in the POSIX subset.
Ncurses2
text terminal library.
Texttools3
ncurses-based library for the Linux console.
GtkAda4
GUI library (actually multiplatform).
54.1.1 Wikibook
• Ada Programming5
• Ada Programming/Libraries6
1 http://en.wikibooks.org/wiki/Ada%20Programming%2FPlatform%2FPOSIX
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FPlatform%2FNcurses
3 http://en.wikibooks.org/wiki/Ada%20Programming%2FPlatform%2FTexttools
4 http://en.wikibooks.org/wiki/Ada%20Programming%2FLibraries%2FGUI%2FGtkAda
5 http://en.wikibooks.org/wiki/Ada%20Programming
6 Chapter 40 on page 331
7 http://www.pegasoft.ca/resources/boblap/book.html
http://www.cs.kuleuven.be/~dirk/ada-belgium/events/06/060226-fosdem-4-ada-in-debian.
8
pdf
9 http://en.wikibooks.org/wiki/User%3ALudovic%20Brenta
377
55 Platform: Windows
The following Libraries and Tools help you when you target the MS-Windows Platform.
GWindows1
Win32 binding
CLAW2
Another Win32 binding that works with any Ada 95 compiler. An introductory edition
is available free of charge for non-commercial use.
GNATCOM3
COM/DCOM/ActiveX binding
GNAVI4
Visual RAD5 (Rapid application development6 ) Development environment
/Console/7
Libraries for console I/O.
/Visual C++ - GNAT interface/8
Guide for calling Ada functions from C++ using GNAT and Visual C++.
55.1.1 Wikibook
• Ada Programming9
• Ada Programming/Libraries10
1 http://en.wikibooks.org/wiki/Ada%20Programming%2FPlatform%2FWindows%2Fwin32binding
2 http://www.rrsoftware.com/html/prodinf/claw/claw.htm
3 http://en.wikibooks.org/wiki/Ada%20Programming%2FPlatform%2FWindows%2Fwin32binding
4 http://en.wikibooks.org/wiki/Ada%20Programming%2FPlatform%2FWindows%2Fwin32binding
5 http://en.wikipedia.org/wiki/Rapid_application_development
6 http://en.wikipedia.org/wiki/Rapid%20application%20development
7 http://en.wikibooks.org/wiki/%2FConsole%2F
8 http://en.wikibooks.org/wiki/%2FVisual%20C%2B%2B%20-%20GNAT%20interface%2F
9 http://en.wikibooks.org/wiki/Ada%20Programming
10 Chapter 40 on page 331
379
56 Platform: Virtual Machines
The following tools help you when you target a virtual machine.
Java1
Programming Ada 95 for Java's JVM (JGnat, AppletMagic)
.NET2
Programming Ada for the .NET Platform (GNAT Pro .NET, A#)
56.1.1 Wikibook
• Ada Programming3
• Ada Programming/Libraries4
1 http://en.wikibooks.org/wiki/Ada%20Programming%2FPlatform%2FVM%2FJava
2 http://en.wikibooks.org/wiki/Ada%20Programming%2FPlatform%2FVM%2FdotNET
3 http://en.wikibooks.org/wiki/Ada%20Programming
4 Chapter 40 on page 331
381
57 Portals
SourceForge1
Currently there are 200 Ada projects hosted at SourceForge — including the example
programs for Ada Programming2 wikibook.
GitHub3
A source code repository based on Git with many recent developments.
Ada-centric forges
There are some Ada-centric forges hosted by Ada associations and individuals:
• http://forge.ada-ru.org
• http://www.ada-france.org:8081
• http://codelabs.ch
• http://scm.ada.cx
BerliOS4
1 http://sourceforge.net/directory/language:ada/
2 https://sourceforge.net/projects/wikibook-ada
3 https://github.com/languages/Ada
4 http://developer.berlios.de/softwaremap/trove_list.php?form_cat=52
5 http://www.adaic.org/ada-resources/tools-libraries/
6 http://www.ohloh.net/languages/21
7 http://www.ohloh.net/tags/ada
8 http://www.ohloh.net/p?page=3&q=language%3Aada&sort=relevance
9 http://freecode.com/tags/ada?sort=vitality&with=&without=
383
Portals
AdaBasis10
AdaBasis consists of about 560 MB of public domain source code and documents, mainly
taken from the Public Ada Library (PAL). The software has been classified and is
presented in a hierarchical manner, separated in different application domains, and, for
some domains, with an additional multi-faceted searching facility.
The intent is to provide students, teachers and researchers with a large collection of
reusable Ada components and systems for use in language and software engineering
courses.
AdaBasis was set up by the Programming Languages Group of the Institut für Informatik
at the University of Stuttgart, Germany. They plan to enlarge the library in the future,
and welcome free public domain contributions. For more informations or to make
suggestions please contact adabasis@informatik.uni-stuttgart.de11
The Public Ada Library (PAL)12
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.
[ftp
//ftp.cs.kuleuven.ac.be/pub/Ada-Belgium/cdrom/index.html Ada and Software Engi-
neering 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 orga-
nizations. Walnut Creek CDROM once sold copies of this library. Nowadays it is no
longer maintained but is still hosted in the Ada Belgium FTP server. It may contain
useful resources, but it is highly redundant with other libraries.
AdaPower13
A directory and collection of Ada tools and resources.
57.4.1 Wikibook
• Ada Programming14
• Ada Programming/Tutorials15
• Ada Programming/Wikis16
10 http://www.iste.uni-stuttgart.de/ps/adabasis.html
11 mailto:adabasis@informatik.uni-stuttgart.de
12 http://www2.informatik.uni-stuttgart.de/iste/ps/ada-software/html/PAL.html
13 http://www.adapower.com/index.php?Command=Packages&Title=Packages+for+Reuse
14 http://en.wikibooks.org/wiki/Ada%20Programming
15 Chapter 58 on page 387
16 http://en.wikibooks.org/wiki/Ada%20Programming%2FWikis
384
57.4.3 Ada Quality and Style Guide
-- does not apply --
385
58 Tutorials
This page contains a list of other Ada tutorials on the Net.
1. Ada Programming1 , available on Wikibooks, is currently the only tutorial based on
the Ada 20052 standard and currently being updated to Ada 20123 .
2. Lovelace4 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 algo-
rithmic 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.
3. AdaTutor5 is an interactive Ada 95 tutorial distributed as a public-domain Ada
program. A web edition6 of the tutorial is also available.
4. The Ada-95: A guide for C and C++ programmers7 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
edition8 .
5. Dale Stanbrough's Introduction9 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.
6. Coronado Enterprises Ada 95 Tutorial: shareware edition10 , commercial edition11 .
1 http://en.wikibooks.org/wiki/Ada%20Programming
2 Chapter 23 on page 219
3 http://en.wikibooks.org/wiki/Ada%20Programming%2FAda%202012
4 http://www.dwheeler.com/lovelace/
5 http://www.adatutor.com/
6 http://zhu-qy.blogspot.com.es/2012/08/adatutor.html
7 http://www.adahome.com/Ammo/Cplpl2Ada.html
8 http://home.agh.edu.pl/~jpi/download/ada/guide-c2ada.pdf
9 http://goanna.cs.rmit.edu.au/~dale/ada/aln.html
10 http://www.infres.enst.fr/~pautet/Ada95/a95list.htm
11 http://www.coronadoenterprises.com/tutorials/ada95/index.html
387
59 Web 2.0
• reddit.com — Ada2 [ RSS3 ], social news website on which users can post links to
content on the web
• Ada Gems4 [ RSS5 ], programming tips and articles about specific language features
• Planet Ada6 [ RSS7 ], an aggregate feed of mostly Ada-related blogs.
• Ada Programming blog8 [ RSS9 ], by Martin Krischik and other authors
• Kickin' the Darkness10 [ RSS11 ], by Marc A. Criley
• Archeia12 [ RSS13 ], by Lucretia
• Pragmatic Revelations14 [ RSS15 ]
1 http://en.wikipedia.org/wiki/Web%202.0
2 http://www.reddit.com/r/ada/
3 http://www.reddit.com/r/ada/.rss
4 http://www.adacore.com/category/developers-center/gems/
5 http://www.adacore.com/rss/gems
6 http://planet.ada.cx/
7 http://planet.ada.cx/rss20.xml
8 http://ada-programming.blogspot.com/
9 http://ada-programming.blogspot.com/feeds/posts/default
10 http://blog.kickin-the-darkness.com/search/label/Ada
11 http://blog.kickin-the-darkness.com/feeds/posts/default
12 http://www.archeia.com/
13 http://www.archeia.com/rss_feed.html
14 http://adrianhoe.com/adrianhoe/category/software_development/ada/
15 http://adrianhoe.com/adrianhoe/feed/rss/
16 http://stackoverflow.com/questions/tagged/ada
17 http://www.linkedin.com/groups?gid=114211
18 http://www.tek-tips.com/threadminder.cfm?pid=199
389
Web 2.0
19 http://www.slideshare.net/
20 http://www.slideshare.net/group/ada-programming/slideshows
21 http://www.slideshare.net/tag/ada-programming
22 http://www.slideshare.net/tag/ada-95
23 http://www.slideshare.net/tag/ada-2005
24 http://www.slideshare.net/tag/ada-2012
25 http://www.ohloh.net/tags/ada
26 http://www.ohloh.net/languages/21
27 http://commons.ada.cx
28 http://ada.krischik.com
29 http://www.wikicfp.com/cfp/call?conference=ada
30 http://www.wikicfp.com/cfp/rss?cat=ada
31 http://www.youtube.com/user/AdaCore05
32 http://en.wikipedia.org/wiki/Category%3AAda%20programming%20language
33 http://en.wikipedia.org/wiki/Ada%20%28programming%20language%29
34 http://en.wikipedia.org/wiki/Jean%20Ichbiah
35 http://en.wikipedia.org/wiki/Beaujolais%20effect
36 http://en.wikipedia.org/wiki/ISO%208652
37 http://en.wikipedia.org/wiki/Ada%20Semantic%20Interface%20Specification
38 http://en.wiktionary.org/wiki/ACATS
39 http://en.wiktionary.org/wiki/Ada
40 http://en.wiktionary.org/wiki/ASIS
41 http://en.wikisource.org/wiki/Steelman%20language%20requirements
42 http://en.wikisource.org/wiki/Stoneman%20requirements
390
• Programación en Ada43 , in Spanish
• Programmation Ada44 , in French
• Ada45 , in Italian
• Wikiquote:
• Programming languages — Ada46
• Wikiversity:
• Ada course47 (you can enroll!)
59.0.9 Projects
• AdaCL52
• The Ada 95 Booch Components53
• The GNU Ada Compiler54
• ASIS55
• GLADE56
• Florist57
• GNAT — GCC Wiki58
• RTEMSAda59
• AVR-Ada60 - Ada compiler for Atmel microcontrollers (Arduinos)
Web 2.061
43 http://en.wikibooks.org/wiki/%3Aes%3AProgramaci%F3n_en_Ada
44 http://en.wikibooks.org/wiki/%3Afr%3AProgrammation_Ada
45 http://en.wikibooks.org/wiki/%3Ait%3AAda
46 http://en.wikiquote.org/wiki/Programming_languages#Ada
47 http://en.wikiversity.org/wiki/Ada
48 http://wikibook-ada.sourceforge.net
49 http://www.rosettacode.org/wiki/Ada
50 http://en.literateprograms.org/Category:Programming_language:Ada
51 http://en.wikipedia.org/wiki/literate%20programming
52 http://adacl.sourceforge.net/index.php
53 http://booch95.sourceforge.net/pmwiki.php
54 http://gnuada.sourceforge.net
55 http://gnat-asis.sourceforge.net
56 http://gnat-glade.sourceforge.net
57 http://gnat-florist.sourceforge.net
58 http://gcc.gnu.org/wiki/GNAT
59 http://www.rtems.com/wiki/index.php/RTEMSAda
60 http://avr-ada.sourceforge.net/
61 http://en.wikibooks.org/wiki/Category%3AAda%20Programming
391
60 Contributors
Edits User
1 A101121
1 ALK2
1 AdRiley3
64 Adrignola4
1 Alan.poindexter5
2 Alisonken16
1 Ammon7
1 Andreas Ipp8
1 Aramael9
1 Arny10
1 Arthurvogel11
7 Avicennasis12
1 Benjstarratt13
14 Carsrac14
56 CarsracBot15
1 Chouclac16
2 Cspurrier17
44 Darklama18
3 David Hoos19
3 Derbeth20
1 Dhenry21
1 http://en.wikibooks.org/w/index.php?title=User:A10112
2 http://en.wikibooks.org/w/index.php?title=User:ALK
3 http://en.wikibooks.org/w/index.php?title=User:AdRiley
4 http://en.wikibooks.org/w/index.php?title=User:Adrignola
5 http://en.wikibooks.org/w/index.php?title=User:Alan.poindexter
6 http://en.wikibooks.org/w/index.php?title=User:Alisonken1
7 http://en.wikibooks.org/w/index.php?title=User:Ammon
8 http://en.wikibooks.org/w/index.php?title=User:Andreas_Ipp
9 http://en.wikibooks.org/w/index.php?title=User:Aramael
10 http://en.wikibooks.org/w/index.php?title=User:Arny
11 http://en.wikibooks.org/w/index.php?title=User:Arthurvogel
12 http://en.wikibooks.org/w/index.php?title=User:Avicennasis
13 http://en.wikibooks.org/w/index.php?title=User:Benjstarratt
14 http://en.wikibooks.org/w/index.php?title=User:Carsrac
15 http://en.wikibooks.org/w/index.php?title=User:CarsracBot
16 http://en.wikibooks.org/w/index.php?title=User:Chouclac
17 http://en.wikibooks.org/w/index.php?title=User:Cspurrier
18 http://en.wikibooks.org/w/index.php?title=User:Darklama
19 http://en.wikibooks.org/w/index.php?title=User:David_Hoos
20 http://en.wikibooks.org/w/index.php?title=User:Derbeth
21 http://en.wikibooks.org/w/index.php?title=User:Dhenry
393
Contributors
12 Dirk Hünniger22
2 Dmitry-kazakov23
1 Doug24
2 DougP25
17 Dragontamer26
1 Fraterm27
1 Friess28
1 Frikk29
1 Frodet30
2 Geocachernemesis31
97 GeorgBauhaus32
8 Godunko33
1 Hagindaz34
1 Herbythyme35
2 JMatthews36
3 James Dennett37
1 Jclee38
1 Jcreem39
1 Jeffinous40
5 Jesselang41
34 Jguk42
1 Jlaire43
2 Jlenthe44
4 Jomegat45
1 Kayau46
22 http://en.wikibooks.org/w/index.php?title=User:Dirk_H%C3%BCnniger
23 http://en.wikibooks.org/w/index.php?title=User:Dmitry-kazakov
24 http://en.wikibooks.org/w/index.php?title=User:Doug
25 http://en.wikibooks.org/w/index.php?title=User:DougP
26 http://en.wikibooks.org/w/index.php?title=User:Dragontamer
27 http://en.wikibooks.org/w/index.php?title=User:Fraterm
28 http://en.wikibooks.org/w/index.php?title=User:Friess
29 http://en.wikibooks.org/w/index.php?title=User:Frikk
30 http://en.wikibooks.org/w/index.php?title=User:Frodet
31 http://en.wikibooks.org/w/index.php?title=User:Geocachernemesis
32 http://en.wikibooks.org/w/index.php?title=User:GeorgBauhaus
33 http://en.wikibooks.org/w/index.php?title=User:Godunko
34 http://en.wikibooks.org/w/index.php?title=User:Hagindaz
35 http://en.wikibooks.org/w/index.php?title=User:Herbythyme
36 http://en.wikibooks.org/w/index.php?title=User:JMatthews
37 http://en.wikibooks.org/w/index.php?title=User:James_Dennett
38 http://en.wikibooks.org/w/index.php?title=User:Jclee
39 http://en.wikibooks.org/w/index.php?title=User:Jcreem
40 http://en.wikibooks.org/w/index.php?title=User:Jeffinous
41 http://en.wikibooks.org/w/index.php?title=User:Jesselang
42 http://en.wikibooks.org/w/index.php?title=User:Jguk
43 http://en.wikibooks.org/w/index.php?title=User:Jlaire
44 http://en.wikibooks.org/w/index.php?title=User:Jlenthe
45 http://en.wikibooks.org/w/index.php?title=User:Jomegat
46 http://en.wikibooks.org/w/index.php?title=User:Kayau
394
1102 Krischik47
1 Kwhitefoot48
16 Larry Luther49
3 LesmanaZimmer50
1 Lincher51
1 Lodacom52
118 Ludovic Brenta53
1 Maciej Sobczak54
2 Mahanga55
463 ManuelGR56
4 Mike.lifeguard57
2 Moskvax58
5 Nikai59
2 Okellogg60
6 Oleszkie61
8 Panic2k462
1 Panzon63
1 Parallelized64
2 Paxton65
1 Per.sandberg66
1 QuiteUnusual67
1 RamaccoloBot68
2 Randhol69
1 Recent Runes70
1 Red4tribe71
47 http://en.wikibooks.org/w/index.php?title=User:Krischik
48 http://en.wikibooks.org/w/index.php?title=User:Kwhitefoot
49 http://en.wikibooks.org/w/index.php?title=User:Larry_Luther
50 http://en.wikibooks.org/w/index.php?title=User:LesmanaZimmer
51 http://en.wikibooks.org/w/index.php?title=User:Lincher
52 http://en.wikibooks.org/w/index.php?title=User:Lodacom
53 http://en.wikibooks.org/w/index.php?title=User:Ludovic_Brenta
54 http://en.wikibooks.org/w/index.php?title=User:Maciej_Sobczak
55 http://en.wikibooks.org/w/index.php?title=User:Mahanga
56 http://en.wikibooks.org/w/index.php?title=User:ManuelGR
57 http://en.wikibooks.org/w/index.php?title=User:Mike.lifeguard
58 http://en.wikibooks.org/w/index.php?title=User:Moskvax
59 http://en.wikibooks.org/w/index.php?title=User:Nikai
60 http://en.wikibooks.org/w/index.php?title=User:Okellogg
61 http://en.wikibooks.org/w/index.php?title=User:Oleszkie
62 http://en.wikibooks.org/w/index.php?title=User:Panic2k4
63 http://en.wikibooks.org/w/index.php?title=User:Panzon
64 http://en.wikibooks.org/w/index.php?title=User:Parallelized
65 http://en.wikibooks.org/w/index.php?title=User:Paxton
66 http://en.wikibooks.org/w/index.php?title=User:Per.sandberg
67 http://en.wikibooks.org/w/index.php?title=User:QuiteUnusual
68 http://en.wikibooks.org/w/index.php?title=User:RamaccoloBot
69 http://en.wikibooks.org/w/index.php?title=User:Randhol
70 http://en.wikibooks.org/w/index.php?title=User:Recent_Runes
71 http://en.wikibooks.org/w/index.php?title=User:Red4tribe
395
Contributors
5 Robert Horning72
1 Rosen73
1 Rursus74
3 SQL75
2 Sam76
5 Sjw77
1 Sparre78
5 Spongebob8879
1 Stephen leake80
711 Suruena81
2 Swhalen82
2 The bellman83
3 Thenub31484
3 Tkoskine85
1 Tobias Bergemann86
1 Van der Hoorn87
3 Venullian88
5 VillemtheVillain!89
1 Vito Genovese90
1 Warinthepocket91
3 WhirlWind92
1 Wikibob93
1 Xania94
1 robot95
72 http://en.wikibooks.org/w/index.php?title=User:Robert_Horning
73 http://en.wikibooks.org/w/index.php?title=User:Rosen
74 http://en.wikibooks.org/w/index.php?title=User:Rursus
75 http://en.wikibooks.org/w/index.php?title=User:SQL
76 http://en.wikibooks.org/w/index.php?title=User:Sam
77 http://en.wikibooks.org/w/index.php?title=User:Sjw
78 http://en.wikibooks.org/w/index.php?title=User:Sparre
79 http://en.wikibooks.org/w/index.php?title=User:Spongebob88
80 http://en.wikibooks.org/w/index.php?title=User:Stephen_leake
81 http://en.wikibooks.org/w/index.php?title=User:Suruena
82 http://en.wikibooks.org/w/index.php?title=User:Swhalen
83 http://en.wikibooks.org/w/index.php?title=User:The_bellman
84 http://en.wikibooks.org/w/index.php?title=User:Thenub314
85 http://en.wikibooks.org/w/index.php?title=User:Tkoskine
86 http://en.wikibooks.org/w/index.php?title=User:Tobias_Bergemann
87 http://en.wikibooks.org/w/index.php?title=User:Van_der_Hoorn
88 http://en.wikibooks.org/w/index.php?title=User:Venullian
89 http://en.wikibooks.org/w/index.php?title=User:VillemtheVillain%21
90 http://en.wikibooks.org/w/index.php?title=User:Vito_Genovese
91 http://en.wikibooks.org/w/index.php?title=User:Warinthepocket
92 http://en.wikibooks.org/w/index.php?title=User:WhirlWind
93 http://en.wikibooks.org/w/index.php?title=User:Wikibob
94 http://en.wikibooks.org/w/index.php?title=User:Xania
http://en.wikibooks.org/w/index.php?title=User:%E3%82%BF%E3%83%81%E3%82%B3%E3%83%9E_
95
robot
396
List of Figures
397
List of Figures
1 ManuelGR97 GFDL
97 http://en.wikibooks.org/wiki/User%3AManuelGR
398
61 Licenses
61.1 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007 ing a Major Component, but which is not part of * a) Convey the object code in, or embodied in, that material or in the Appropriate Legal Notices
Copyright © 2007 Free Software Foundation, Inc. that Major Component, and (b) serves only to en- a physical product (including a physical distribu- displayed by works containing it; or * c) Prohibit-
<http://fsf.org/> able use of the work with that Major Component, tion medium), accompanied by the Corresponding ing misrepresentation of the origin of that material,
Everyone is permitted to copy and distribute verba- or to implement a Standard Interface for which an Source fixed on a durable physical medium custom- or requiring that modified versions of such material
tim copies of this license document, but changing implementation is available to the public in source arily used for software interchange. * b) Convey the be marked in reasonable ways as different from the
it is not allowed. Preamble code form. A “Major Component”, in this context, object code in, or embodied in, a physical product original version; or * d) Limiting the use for pub-
The GNU General Public License is a free, copyleft means a major essential component (kernel, window (including a physical distribution medium), accom- licity purposes of names of licensors or authors of
license for software and other kinds of works. system, and so on) of the specific operating system panied by a written offer, valid for at least three the material; or * e) Declining to grant rights under
The licenses for most software and other practi- (if any) on which the executable work runs, or a years and valid for as long as you offer spare parts trademark law for use of some trade names, trade-
cal works are designed to take away your freedom compiler used to produce the work, or an object or customer support for that product model, to marks, or service marks; or * f) Requiring indem-
to share and change the works. By contrast, the code interpreter used to run it. give anyone who possesses the object code either nification of licensors and authors of that material
GNU General Public License is intended to guaran- The “Corresponding Source” for a work in object (1) a copy of the Corresponding Source for all the by anyone who conveys the material (or modified
tee your freedom to share and change all versions code form means all the source code needed to gen- software in the product that is covered by this Li- versions of it) with contractual assumptions of lia-
of a program–to make sure it remains free software erate, install, and (for an executable work) run cense, on a durable physical medium customarily bility to the recipient, for any liability that these
for all its users. We, the Free Software Foundation, the object code and to modify the work, including used for software interchange, for a price no more contractual assumptions directly impose on those
use the GNU General Public License for most of our scripts to control those activities. However, it does than your reasonable cost of physically performing licensors and authors.
software; it applies also to any other work released not include the work’s System Libraries, or general- this conveying of source, or (2) access to copy the All other non-permissive additional terms are con-
this way by its authors. You can apply it to your purpose tools or generally available free programs Corresponding Source from a network server at no sidered “further restrictions” within the meaning of
programs, too. which are used unmodified in performing those ac- charge. * c) Convey individual copies of the object section 10. If the Program as you received it, or any
When we speak of free software, we are referring tivities but which are not part of the work. For code with a copy of the written offer to provide part of it, contains a notice stating that it is gov-
to freedom, not price. Our General Public Li- example, Corresponding Source includes interface the Corresponding Source. This alternative is al- erned by this License along with a term that is a
censes are designed to make sure that you have definition files associated with source files for the lowed only occasionally and noncommercially, and further restriction, you may remove that term. If a
the freedom to distribute copies of free software work, and the source code for shared libraries and only if you received the object code with such an of- license document contains a further restriction but
(and charge for them if you wish), that you receive dynamically linked subprograms that the work is fer, in accord with subsection 6b. * d) Convey the permits relicensing or conveying under this License,
source code or can get it if you want it, that you specifically designed to require, such as by intimate object code by offering access from a designated you may add to a covered work material governed
can change the software or use pieces of it in new data communication or control flow between those place (gratis or for a charge), and offer equivalent by the terms of that license document, provided
free programs, and that you know you can do these subprograms and other parts of the work. access to the Corresponding Source in the same way that the further restriction does not survive such
things. The Corresponding Source need not include any- through the same place at no further charge. You relicensing or conveying.
To protect your rights, we need to prevent others thing that users can regenerate automatically from need not require recipients to copy the Correspond- If you add terms to a covered work in accord with
from denying you these rights or asking you to sur- other parts of the Corresponding Source. ing Source along with the object code. If the place this section, you must place, in the relevant source
render the rights. Therefore, you have certain re- The Corresponding Source for a work in source code to copy the object code is a network server, the Cor- files, a statement of the additional terms that ap-
sponsibilities if you distribute copies of the soft- form is that same work. 2. Basic Permissions. responding Source may be on a different server (op- ply to those files, or a notice indicating where to
ware, or if you modify it: responsibilities to respect All rights granted under this License are granted erated by you or a third party) that supports equiv- find the applicable terms.
the freedom of others. for the term of copyright on the Program, and are alent copying facilities, provided you maintain clear Additional terms, permissive or non-permissive,
For example, if you distribute copies of such a pro- irrevocable provided the stated conditions are met. directions next to the object code saying where to may be stated in the form of a separately written
gram, whether gratis or for a fee, you must pass This License explicitly affirms your unlimited per- find the Corresponding Source. Regardless of what license, or stated as exceptions; the above require-
on to the recipients the same freedoms that you re- mission to run the unmodified Program. The out- server hosts the Corresponding Source, you remain ments apply either way. 8. Termination.
ceived. You must make sure that they, too, receive put from running a covered work is covered by this obligated to ensure that it is available for as long You may not propagate or modify a covered work
or can get the source code. And you must show License only if the output, given its content, con- as needed to satisfy these requirements. * e) Con- except as expressly provided under this License
them these terms so they know their rights. stitutes a covered work. This License acknowledges vey the object code using peer-to-peer transmission, Any attempt otherwise to propagate or modify it is
Developers that use the GNU GPL protect your your rights of fair use or other equivalent, as pro- provided you inform other peers where the object void, and will automatically terminate your rights
rights with two steps: (1) assert copyright on the vided by copyright law. code and Corresponding Source of the work are be- under this License (including any patent licenses
software, and (2) offer you this License giving you You may make, run and propagate covered works ing offered to the general public at no charge under granted under the third paragraph of section 11).
legal permission to copy, distribute and/or modify that you do not convey, without conditions so long subsection 6d. However, if you cease all violation of this License,
it. as your license otherwise remains in force. You may A separable portion of the object code, whose then your license from a particular copyright holder
For the developers’ and authors’ protection, the convey covered works to others for the sole purpose source code is excluded from the Corresponding is reinstated (a) provisionally, unless and until the
GPL clearly explains that there is no warranty for of having them make modifications exclusively for Source as a System Library, need not be included copyright holder explicitly and finally terminates
this free software. For both users’ and authors’ you, or provide you with facilities for running those in conveying the object code work. your license, and (b) permanently, if the copyright
sake, the GPL requires that modified versions be works, provided that you comply with the terms A “User Product” is either (1) a “consumer prod- holder fails to notify you of the violation by some
marked as changed, so that their problems will not of this License in conveying all material for which uct”, which means any tangible personal property reasonable means prior to 60 days after the cessa-
be attributed erroneously to authors of previous you do not control copyright. Those thus making or which is normally used for personal, family, or tion.
versions. running the covered works for you must do so exclu- household purposes, or (2) anything designed or Moreover, your license from a particular copyright
Some devices are designed to deny users access to sively on your behalf, under your direction and con- sold for incorporation into a dwelling. In deter- holder is reinstated permanently if the copyright
install or run modified versions of the software in- trol, on terms that prohibit them from making any mining whether a product is a consumer product, holder notifies you of the violation by some reason-
side them, although the manufacturer can do so. copies of your copyrighted material outside their doubtful cases shall be resolved in favor of cover- able means, this is the first time you have received
This is fundamentally incompatible with the aim relationship with you. age. For a particular product received by a par- notice of violation of this License (for any work)
of protecting users’ freedom to change the software. Conveying under any other circumstances is permit- ticular user, “normally used” refers to a typical or from that copyright holder, and you cure the vi-
The systematic pattern of such abuse occurs in the ted solely under the conditions stated below. Subli- common use of that class of product, regardless of olation prior to 30 days after your receipt of the
area of products for individuals to use, which is censing is not allowed; section 10 makes it unneces- the status of the particular user or of the way in notice.
precisely where it is most unacceptable. Therefore, sary. 3. Protecting Users’ Legal Rights From Anti- which the particular user actually uses, or expects Termination of your rights under this section does
we have designed this version of the GPL to pro- Circumvention Law. or is expected to use, the product. A product is a not terminate the licenses of parties who have re-
hibit the practice for those products. If such prob- No covered work shall be deemed part of an effec- consumer product regardless of whether the prod- ceived copies or rights from you under this License
lems arise substantially in other domains, we stand tive technological measure under any applicable law uct has substantial commercial, industrial or non- If your rights have been terminated and not perma-
ready to extend this provision to those domains in fulfilling obligations under article 11 of the WIPO consumer uses, unless such uses represent the only nently reinstated, you do not qualify to receive new
future versions of the GPL, as needed to protect copyright treaty adopted on 20 December 1996, or significant mode of use of the product. licenses for the same material under section 10. 9
the freedom of users. similar laws prohibiting or restricting circumven- “Installation Information” for a User Product Acceptance Not Required for Having Copies.
Finally, every program is threatened constantly by tion of such measures. means any methods, procedures, authorization You are not required to accept this License in or-
software patents. States should not allow patents When you convey a covered work, you waive any keys, or other information required to install and der to receive or run a copy of the Program. Ancil-
to restrict development and use of software on legal power to forbid circumvention of technologi- execute modified versions of a covered work in that lary propagation of a covered work occurring solely
general-purpose computers, but in those that do, cal measures to the extent such circumvention is ef- User Product from a modified version of its Corre- as a consequence of using peer-to-peer transmission
we wish to avoid the special danger that patents fected by exercising rights under this License with sponding Source. The information must suffice to to receive a copy likewise does not require accep-
applied to a free program could make it effectively respect to the covered work, and you disclaim any ensure that the continued functioning of the modi- tance. However, nothing other than this License
proprietary. To prevent this, the GPL assures that intention to limit operation or modification of the fied object code is in no case prevented or interfered grants you permission to propagate or modify any
patents cannot be used to render the program non- work as a means of enforcing, against the work’s with solely because modification has been made. covered work. These actions infringe copyright if
free. users, your or third parties’ legal rights to forbid If you convey an object code work under this sec- you do not accept this License. Therefore, by mod-
The precise terms and conditions for copying, dis- circumvention of technological measures. 4. Con- tion in, or with, or specifically for use in, a User ifying or propagating a covered work, you indicate
tribution and modification follow. TERMS AND veying Verbatim Copies. Product, and the conveying occurs as part of a your acceptance of this License to do so. 10. Auto-
CONDITIONS 0. Definitions. You may convey verbatim copies of the Program’s transaction in which the right of possession and matic Licensing of Downstream Recipients.
“This License” refers to version 3 of the GNU Gen- source code as you receive it, in any medium, pro- use of the User Product is transferred to the re- Each time you convey a covered work, the recipient
eral Public License. vided that you conspicuously and appropriately cipient in perpetuity or for a fixed term (regard- automatically receives a license from the original
“Copyright” also means copyright-like laws that ap- publish on each copy an appropriate copyright no- less of how the transaction is characterized), the licensors, to run, modify and propagate that work,
ply to other kinds of works, such as semiconductor tice; keep intact all notices stating that this License Corresponding Source conveyed under this section subject to this License. You are not responsible
masks. and any non-permissive terms added in accord with must be accompanied by the Installation Informa- for enforcing compliance by third parties with this
“The Program” refers to any copyrightable work section 7 apply to the code; keep intact all notices tion. But this requirement does not apply if neither License.
licensed under this License. Each licensee is ad- of the absence of any warranty; and give all recipi- you nor any third party retains the ability to install An “entity transaction” is a transaction transfer-
dressed as “you”. “Licensees” and “recipients” may ents a copy of this License along with the Program. modified object code on the User Product (for ex- ring control of an organization, or substantially all
be individuals or organizations. You may charge any price or no price for each copy ample, the work has been installed in ROM). assets of one, or subdividing an organization, or
To “modify” a work means to copy from or adapt that you convey, and you may offer support or war- The requirement to provide Installation Informa- merging organizations. If propagation of a cov-
all or part of the work in a fashion requiring copy- ranty protection for a fee. 5. Conveying Modified tion does not include a requirement to continue to ered work results from an entity transaction, each
right permission, other than the making of an exact Source Versions. provide support service, warranty, or updates for a party to that transaction who receives a copy of the
copy. The resulting work is called a “modified ver- You may convey a work based on the Program, or work that has been modified or installed by the re- work also receives whatever licenses to the work the
sion” of the earlier work or a work “based on” the the modifications to produce it from the Program, cipient, or for the User Product in which it has been party’s predecessor in interest had or could give un-
earlier work. in the form of source code under the terms of sec- modified or installed. Access to a network may be der the previous paragraph, plus a right to posses-
A “covered work” means either the unmodified Pro- tion 4, provided that you also meet all of these con- denied when the modification itself materially and sion of the Corresponding Source of the work from
gram or a work based on the Program. ditions: adversely affects the operation of the network or the predecessor in interest, if the predecessor has it
To “propagate” a work means to do anything with it * a) The work must carry prominent notices stating violates the rules and protocols for communication or can get it with reasonable efforts.
that, without permission, would make you directly that you modified it, and giving a relevant date. * across the network. You may not impose any further restrictions on the
or secondarily liable for infringement under appli- b) The work must carry prominent notices stating Corresponding Source conveyed, and Installation exercise of the rights granted or affirmed under this
cable copyright law, except executing it on a com- that it is released under this License and any con- Information provided, in accord with this section License. For example, you may not impose a license
puter or modifying a private copy. Propagation in- ditions added under section 7. This requirement must be in a format that is publicly documented fee, royalty, or other charge for exercise of rights
cludes copying, distribution (with or without mod- modifies the requirement in section 4 to “keep in- (and with an implementation available to the public granted under this License, and you may not ini-
ification), making available to the public, and in tact all notices”. * c) You must license the entire in source code form), and must require no special tiate litigation (including a cross-claim or counter-
some countries other activities as well. work, as a whole, under this License to anyone who password or key for unpacking, reading or copying. claim in a lawsuit) alleging that any patent claim
To “convey” a work means any kind of propagation comes into possession of a copy. This License will 7. Additional Terms. is infringed by making, using, selling, offering for
that enables other parties to make or receive copies. therefore apply, along with any applicable section 7 “Additional permissions” are terms that supplement sale, or importing the Program or any portion of it
Mere interaction with a user through a computer additional terms, to the whole of the work, and all the terms of this License by making exceptions from 11. Patents.
network, with no transfer of a copy, is not convey- its parts, regardless of how they are packaged. This one or more of its conditions. Additional permis- A “contributor” is a copyright holder who autho-
ing. License gives no permission to license the work in sions that are applicable to the entire Program rizes use under this License of the Program or a
An interactive user interface displays “Appropriate any other way, but it does not invalidate such per- shall be treated as though they were included in work on which the Program is based. The work
Legal Notices” to the extent that it includes a con- mission if you have separately received it. * d) If this License, to the extent that they are valid un- thus licensed is called the contributor’s “contribu-
venient and prominently visible feature that (1) dis- the work has interactive user interfaces, each must der applicable law. If additional permissions apply tor version”.
plays an appropriate copyright notice, and (2) tells display Appropriate Legal Notices; however, if the only to part of the Program, that part may be used A contributor’s “essential patent claims” are all
the user that there is no warranty for the work (ex- Program has interactive interfaces that do not dis- separately under those permissions, but the entire patent claims owned or controlled by the contribu-
cept to the extent that warranties are provided), play Appropriate Legal Notices, your work need not Program remains governed by this License without tor, whether already acquired or hereafter acquired,
that licensees may convey the work under this Li- make them do so. regard to the additional permissions. that would be infringed by some manner, permit-
cense, and how to view a copy of this License. If A compilation of a covered work with other sepa- When you convey a copy of a covered work, you may ted by this License, of making, using, or selling its
the interface presents a list of user commands or rate and independent works, which are not by their at your option remove any additional permissions contributor version, but do not include claims that
options, such as a menu, a prominent item in the nature extensions of the covered work, and which from that copy, or from any part of it. (Additional would be infringed only as a consequence of further
list meets this criterion. 1. Source Code. are not combined with it such as to form a larger permissions may be written to require their own re- modification of the contributor version. For pur-
The “source code” for a work means the preferred program, in or on a volume of a storage or distri- moval in certain cases when you modify the work.) poses of this definition, “control” includes the right
form of the work for making modifications to it. bution medium, is called an “aggregate” if the com- You may place additional permissions on material, to grant patent sublicenses in a manner consistent
“Object code” means any non-source form of a pilation and its resulting copyright are not used to added by you to a covered work, for which you have with the requirements of this License.
work. limit the access or legal rights of the compilation’s or can give appropriate copyright permission. Each contributor grants you a non-exclusive, world-
A “Standard Interface” means an interface that ei- users beyond what the individual works permit. In- Notwithstanding any other provision of this Li- wide, royalty-free patent license under the contrib-
ther is an official standard defined by a recognized clusion of a covered work in an aggregate does not cense, for material you add to a covered work, you utor’s essential patent claims, to make, use, sell, of-
standards body, or, in the case of interfaces spec- cause this License to apply to the other parts of the may (if authorized by the copyright holders of that fer for sale, import and otherwise run, modify and
ified for a particular programming language, one aggregate. 6. Conveying Non-Source Forms. material) supplement the terms of this License with propagate the contents of its contributor version.
that is widely used among developers working in You may convey a covered work in object code form terms: In the following three paragraphs, a “patent li-
that language. under the terms of sections 4 and 5, provided that * a) Disclaiming warranty or limiting liability dif- cense” is any express agreement or commitment,
The “System Libraries” of an executable work in- you also convey the machine-readable Correspond- ferently from the terms of sections 15 and 16 of this however denominated, not to enforce a patent (such
clude anything, other than the work as a whole, ing Source under the terms of this License, in one License; or * b) Requiring preservation of specified as an express permission to practice a patent or
that (a) is included in the normal form of packag- of these ways: reasonable legal notices or author attributions in covenant not to sue for patent infringement). To
“grant” such a patent license to a party means to able to you under applicable patent law. 12. No THERE IS NO WARRANTY FOR THE PRO- the “copyright” line and a pointer to where the f
make such an agreement or commitment not to en- Surrender of Others’ Freedom. GRAM, TO THE EXTENT PERMITTED BY AP- notice is found.
force a patent against the party. If conditions are imposed on you (whether by court PLICABLE LAW. EXCEPT WHEN OTHERWISE <one line to give the program’s name and a br
If you convey a covered work, knowingly relying order, agreement or otherwise) that contradict the STATED IN WRITING THE COPYRIGHT HOLD- idea of what it does.> Copyright (C) <yea
on a patent license, and the Corresponding Source conditions of this License, they do not excuse you ERS AND/OR OTHER PARTIES PROVIDE THE <name of author>
of the work is not available for anyone to copy, from the conditions of this License. If you cannot PROGRAM “AS IS” WITHOUT WARRANTY OF This program is free software: you can redistribu
free of charge and under the terms of this License, convey a covered work so as to satisfy simultane- ANY KIND, EITHER EXPRESSED OR IMPLIED, it and/or modify it under the terms of the GN
through a publicly available network server or other ously your obligations under this License and any INCLUDING, BUT NOT LIMITED TO, THE IM- General Public License as published by the Fr
readily accessible means, then you must either (1) other pertinent obligations, then as a consequence PLIED WARRANTIES OF MERCHANTABILITY Software Foundation, either version 3 of the
cause the Corresponding Source to be so available, you may not convey it at all. For example, if you AND FITNESS FOR A PARTICULAR PURPOSE. cense, or (at your option) any later version.
or (2) arrange to deprive yourself of the benefit agree to terms that obligate you to collect a roy- THE ENTIRE RISK AS TO THE QUALITY AND This program is distributed in the hope th
of the patent license for this particular work, or alty for further conveying from those to whom you PERFORMANCE OF THE PROGRAM IS WITH it will be useful, but WITHOUT ANY WA
(3) arrange, in a manner consistent with the re- convey the Program, the only way you could satisfy YOU. SHOULD THE PROGRAM PROVE DEFEC- RANTY; without even the implied warranty
quirements of this License, to extend the patent both those terms and this License would be to re- TIVE, YOU ASSUME THE COST OF ALL NECES- MERCHANTABILITY or FITNESS FOR A PA
license to downstream recipients. “Knowingly re- frain entirely from conveying the Program. 13. Use SARY SERVICING, REPAIR OR CORRECTION. TICULAR PURPOSE. See the GNU General Pub
lying” means you have actual knowledge that, but with the GNU Affero General Public License. 16. Limitation of Liability. License for more details.
for the patent license, your conveying the covered Notwithstanding any other provision of this Li- IN NO EVENT UNLESS REQUIRED BY APPLI- You should have received a copy of the GNU G
work in a country, or your recipient’s use of the cov- cense, you have permission to link or combine any CABLE LAW OR AGREED TO IN WRITING eral Public License along with this program. If n
ered work in a country, would infringe one or more covered work with a work licensed under version WILL ANY COPYRIGHT HOLDER, OR ANY see <http://www.gnu.org/licenses/>.
identifiable patents in that country that you have 3 of the GNU Affero General Public License into OTHER PARTY WHO MODIFIES AND/OR CON- Also add information on how to contact you by el
reason to believe are valid. a single combined work, and to convey the result- VEYS THE PROGRAM AS PERMITTED ABOVE, tronic and paper mail.
If, pursuant to or in connection with a single trans- ing work. The terms of this License will continue BE LIABLE TO YOU FOR DAMAGES, IN- If the program does terminal interaction, make
action or arrangement, you convey, or propagate to apply to the part which is the covered work, but CLUDING ANY GENERAL, SPECIAL, INCIDEN- output a short notice like this when it starts in
by procuring conveyance of, a covered work, and the special requirements of the GNU Affero General TAL OR CONSEQUENTIAL DAMAGES ARISING interactive mode:
grant a patent license to some of the parties re- Public License, section 13, concerning interaction OUT OF THE USE OR INABILITY TO USE <program> Copyright (C) <year> <name of a
ceiving the covered work authorizing them to use, through a network will apply to the combination THE PROGRAM (INCLUDING BUT NOT LIM- thor> This program comes with ABSOLUTEL
propagate, modify or convey a specific copy of the as such. 14. Revised Versions of this License. ITED TO LOSS OF DATA OR DATA BEING REN- NO WARRANTY; for details type ‘show w’. This
covered work, then the patent license you grant is The Free Software Foundation may publish revised DERED INACCURATE OR LOSSES SUSTAINED free software, and you are welcome to redistribute
automatically extended to all recipients of the cov- and/or new versions of the GNU General Public Li- BY YOU OR THIRD PARTIES OR A FAILURE under certain conditions; type ‘show c’ for detai
ered work and works based on it. cense from time to time. Such new versions will be OF THE PROGRAM TO OPERATE WITH ANY The hypothetical commands ‘show w’ and ‘show
A patent license is “discriminatory” if it does not in- similar in spirit to the present version, but may dif- OTHER PROGRAMS), EVEN IF SUCH HOLDER should show the appropriate parts of the Gene
clude within the scope of its coverage, prohibits the fer in detail to address new problems or concerns. OR OTHER PARTY HAS BEEN ADVISED OF Public License. Of course, your program’s co
exercise of, or is conditioned on the non-exercise Each version is given a distinguishing version num- THE POSSIBILITY OF SUCH DAMAGES. 17. In- mands might be different; for a GUI interface, y
of one or more of the rights that are specifically ber. If the Program specifies that a certain num- terpretation of Sections 15 and 16. would use an “about box”.
granted under this License. You may not convey a bered version of the GNU General Public License If the disclaimer of warranty and limitation of lia- You should also get your employer (if you wo
covered work if you are a party to an arrangement “or any later version” applies to it, you have the bility provided above cannot be given local legal ef- as a programmer) or school, if any, to sign
with a third party that is in the business of dis- option of following the terms and conditions either fect according to their terms, reviewing courts shall “copyright disclaimer” for the program, if n
tributing software, under which you make payment of that numbered version or of any later version apply local law that most closely approximates an essary. For more information on this, a
to the third party based on the extent of your ac- published by the Free Software Foundation. If the absolute waiver of all civil liability in connection how to apply and follow the GNU GPL, s
tivity of conveying the work, and under which the Program does not specify a version number of the with the Program, unless a warranty or assumption <http://www.gnu.org/licenses/>.
third party grants, to any of the parties who would GNU General Public License, you may choose any of liability accompanies a copy of the Program in The GNU General Public License does not perm
receive the covered work from you, a discrimina- version ever published by the Free Software Foun- return for a fee. incorporating your program into proprietary p
tory patent license (a) in connection with copies dation. END OF TERMS AND CONDITIONS How to Ap- grams. If your program is a subroutine library, y
of the covered work conveyed by you (or copies If the Program specifies that a proxy can decide ply These Terms to Your New Programs may consider it more useful to permit linking p
made from those copies), or (b) primarily for and in which future versions of the GNU General Public If you develop a new program, and you want it to prietary applications with the library. If this
connection with specific products or compilations License can be used, that proxy’s public statement be of the greatest possible use to the public, the what you want to do, use the GNU Lesser Gene
that contain the covered work, unless you entered of acceptance of a version permanently authorizes best way to achieve this is to make it free software Public License instead of this License. But fir
into that arrangement, or that patent license was you to choose that version for the Program. which everyone can redistribute and change under please read <http://www.gnu.org/philosophy/wh
granted, prior to 28 March 2007. Later license versions may give you additional or these terms. not-lgpl.html>.
Nothing in this License shall be construed as ex- different permissions. However, no additional obli- To do so, attach the following notices to the pro-
cluding or limiting any implied license or other de- gations are imposed on any author or copyright gram. It is safest to attach them to the start of
fenses to infringement that may otherwise be avail- holder as a result of your choosing to follow a later each source file to most effectively state the exclu-
version. 15. Disclaimer of Warranty. sion of warranty; and each file should have at least
GNU LESSER GENERAL PUBLIC LICENSE System Libraries of the Combined Work. 1. Excep- gineering for debugging such modifications, if you You may place library facilities that are a work
Version 3, 29 June 2007 tion to Section 3 of the GNU GPL. also do each of the following: based on the Library side by side in a single library
Copyright © 2007 Free Software Foundation, Inc. You may convey a covered work under sections 3 * a) Give prominent notice with each copy of the together with other library facilities that are not
<http://fsf.org/> and 4 of this License without being bound by sec- Combined Work that the Library is used in it and Applications and are not covered by this License,
Everyone is permitted to copy and distribute verba- tion 3 of the GNU GPL. 2. Conveying Modified that the Library and its use are covered by this Li- and convey such a combined library under terms of
tim copies of this license document, but changing Versions. cense. * b) Accompany the Combined Work with a your choice, if you do both of the following:
it is not allowed. If you modify a copy of the Library, and, in your copy of the GNU GPL and this license document. * * a) Accompany the combined library with a copy
This version of the GNU Lesser General Public Li- modifications, a facility refers to a function or data c) For a Combined Work that displays copyright no- of the same work based on the Library, uncombined
cense incorporates the terms and conditions of ver- to be supplied by an Application that uses the fa- tices during execution, include the copyright notice with any other library facilities, conveyed under
sion 3 of the GNU General Public License, supple- cility (other than as an argument passed when the for the Library among these notices, as well as a ref- the terms of this License. * b) Give prominent no-
mented by the additional permissions listed below. facility is invoked), then you may convey a copy of erence directing the user to the copies of the GNU tice with the combined library that part of it is a
0. Additional Definitions. the modified version: GPL and this license document. * d) Do one of the work based on the Library, and explaining where
As used herein, “this License” refers to version 3 * a) under this License, provided that you make a following: o 0) Convey the Minimal Corresponding to find the accompanying uncombined form of the
of the GNU Lesser General Public License, and the good faith effort to ensure that, in the event an Ap- Source under the terms of this License, and the Cor- same work.
“GNU GPL” refers to version 3 of the GNU General plication does not supply the function or data, the responding Application Code in a form suitable for, 6. Revised Versions of the GNU Lesser General
Public License. facility still operates, and performs whatever part and under terms that permit, the user to recombine Public License.
“The Library” refers to a covered work governed by of its purpose remains meaningful, or * b) under or relink the Application with a modified version The Free Software Foundation may publish revised
this License, other than an Application or a Com- the GNU GPL, with none of the additional permis- of the Linked Version to produce a modified Com- and/or new versions of the GNU Lesser General
bined Work as defined below. sions of this License applicable to that copy. bined Work, in the manner specified by section 6 of Public License from time to time. Such new ver-
An “Application” is any work that makes use of an 3. Object Code Incorporating Material from Li- the GNU GPL for conveying Corresponding Source. sions will be similar in spirit to the present version,
interface provided by the Library, but which is not brary Header Files. o 1) Use a suitable shared library mechanism for but may differ in detail to address new problems or
otherwise based on the Library. Defining a subclass The object code form of an Application may incor- linking with the Library. A suitable mechanism concerns.
of a class defined by the Library is deemed a mode porate material from a header file that is part of is one that (a) uses at run time a copy of the Li- Each version is given a distinguishing version num-
of using an interface provided by the Library. the Library. You may convey such object code un- brary already present on the user’s computer sys- ber. If the Library as you received it specifies that
A “Combined Work” is a work produced by com- der terms of your choice, provided that, if the in- tem, and (b) will operate properly with a modified a certain numbered version of the GNU Lesser Gen-
bining or linking an Application with the Library. corporated material is not limited to numerical pa- version of the Library that is interface-compatible eral Public License “or any later version” applies to
The particular version of the Library with which rameters, data structure layouts and accessors, or with the Linked Version. * e) Provide Installation it, you have the option of following the terms and
the Combined Work was made is also called the small macros, inline functions and templates (ten Information, but only if you would otherwise be re- conditions either of that published version or of any
“Linked Version”. or fewer lines in length), you do both of the follow- quired to provide such information under section 6 later version published by the Free Software Foun-
The “Minimal Corresponding Source” for a Com- ing: of the GNU GPL, and only to the extent that such dation. If the Library as you received it does not
bined Work means the Corresponding Source for * a) Give prominent notice with each copy of the information is necessary to install and execute a specify a version number of the GNU Lesser Gen-
the Combined Work, excluding any source code for object code that the Library is used in it and that modified version of the Combined Work produced eral Public License, you may choose any version of
portions of the Combined Work that, considered in the Library and its use are covered by this License. by recombining or relinking the Application with the GNU Lesser General Public License ever pub-
isolation, are based on the Application, and not on * b) Accompany the object code with a copy of the a modified version of the Linked Version. (If you lished by the Free Software Foundation.
the Linked Version. GNU GPL and this license document. use option 4d0, the Installation Information must If the Library as you received it specifies that a
The “Corresponding Application Code” for a Com- 4. Combined Works. accompany the Minimal Corresponding Source and proxy can decide whether future versions of the
bined Work means the object code and/or source You may convey a Combined Work under terms of Corresponding Application Code. If you use option GNU Lesser General Public License shall apply,
code for the Application, including any data and your choice that, taken together, effectively do not 4d1, you must provide the Installation Information that proxy’s public statement of acceptance of
utility programs needed for reproducing the Com- restrict modification of the portions of the Library in the manner specified by section 6 of the GNU any version is permanent authorization for you to
bined Work from the Application, but excluding the contained in the Combined Work and reverse en- GPL for conveying Corresponding Source.) choose that version for the Library.
5. Combined Libraries.