0% found this document useful (0 votes)
12 views17 pages

Ada (Programming Language)

Ada is a high-level, structured, statically typed programming language designed for safety and maintainability, particularly in embedded and real-time systems. Originally developed for the US Department of Defense, it features strong typing, modular programming, and built-in support for concurrency and exception handling. The language has undergone several revisions, with the most recent standard being Ada 2012, and is widely used in critical applications such as avionics and air traffic control.

Uploaded by

turing1946
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views17 pages

Ada (Programming Language)

Ada is a high-level, structured, statically typed programming language designed for safety and maintainability, particularly in embedded and real-time systems. Originally developed for the US Department of Defense, it features strong typing, modular programming, and built-in support for concurrency and exception handling. The language has undergone several revisions, with the most recent standard being Ada 2012, and is widely used in critical applications such as avionics and air traffic control.

Uploaded by

turing1946
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Ada (programming language)

Ada is a structured, statically typed, imperative, and object-


oriented high-level programming language, extended from Pascal
Ada
and other languages. It has built-in language support for design by
contract (DbC), extremely strong typing, explicit concurrency,
tasks, synchronous message passing, protected objects, and non-
determinism. Ada improves code safety and maintainability by
using the compiler to find errors in favor of runtime errors. Ada is
an international technical standard, jointly defined by the
International Organization for Standardization (ISO), and the
International Electrotechnical Commission (IEC). As of 2020, the Paradigm Multi-paradigm:
standard, called Ada 2012 informally,[13] is ISO/IEC structured,
8652:2012.[14] imperative, object-
Ada was originally designed by a team led by French computer oriented, aspect-
scientist Jean Ichbiah of CII Honeywell Bull under contract to the oriented,[1]
United States Department of Defense (DoD) from 1977 to 1983 to concurrent, array,
distributed,
generic,
procedural, meta
Family Pascal
Designed by
MIL-STD-
1815, Ada 83:
Jean Ichbiah
Ada 95:
Tucker Taft
Ada 2005:
Tucker Taft
Ada 2012:
Tucker Taft

First appeared February 1980

Stable release Ada 2012 TC1[2][3]


Typing static, strong,
discipline safe, nominative
OS Multi- or cross-
platform
Filename .adb, .ads
extensions
Website [Link] (ht
tps://[Link]
g/)
supersede over 450 programming languages used by the DoD at Major implementations
that time.[15] Ada was named after Ada Lovelace (1815–1852),
AdaCore GNAT,[4]
who has been credited as the first computer programmer.[16]
Green Hills Software Optimising
Ada 95 compiler,
PTC ApexAda and ObjectAda,[5]
Contents MapuSoft Ada-C/C++ changer,[6]
formerly known as "AdaMagic with
Features
C Intermediate",[7]
History DDC-I Score
Standardization Dialects
Language constructs
SPARK, Ravenscar profile
"Hello, world!" in Ada
Influenced by
Data types
Control structures ALGOL 68, Pascal, Simula 67,[8]
Packages, procedures and functions C++ (Ada 95), Smalltalk (Ada 95),
Concurrency Modula-2 (Ada 95) Java (Ada
Pragmas 2005), Eiffel (Ada 2012)

Generics Influenced

See also C++, Chapel,[9] Drago,[10] D, Eiffel,


Griffin,[11] Java, Nim, ParaSail,
References
PL/SQL, PL/pgSQL, Python, Ruby,
International standards
Seed7, SPARforte,[12] Sparkel,
Rationale
SQL/PSM, VHDL
Books
Archives Ada Programming at Wikibooks

External links

Features
Ada was originally designed for embedded and real-time systems. The Ada 95 revision, designed by S.
Tucker Taft of Intermetrics between 1992 and 1995, improved support for systems, numerical, financial,
and object-oriented programming (OOP).

Features of Ada include: strong typing, modular programming mechanisms (packages), run-time checking,
parallel processing (tasks, synchronous message passing, protected objects, and nondeterministic select
statements), exception handling, and generics. Ada 95 added support for object-oriented programming,
including dynamic dispatch.

The syntax of Ada minimizes choices of ways to perform basic operations, and prefers English keywords
(such as "or else" and "and then") to symbols (such as "||" and "&&"). Ada uses the basic arithmetical
operators "+", "-", "*", and "/", but avoids using other symbols. Code blocks are delimited by words such
as "declare", "begin", and "end", where the "end" (in most cases) is followed by the identifier of the block
it closes (e.g., if ... end if, loop ... end loop). In the case of conditional blocks this avoids a dangling else that
could pair with the wrong nested if-expression in other languages like C or Java.

Ada is designed for developing very large software systems. Ada packages can be compiled separately.
Ada package specifications (the package interface) can also be compiled separately without the
implementation to check for consistency. This makes it possible to detect problems early during the design
phase, before implementation starts.

A large number of compile-time checks are supported to help avoid bugs that would not be detectable until
run-time in some other languages or would require explicit checks to be added to the source code. For
example, the syntax requires explicitly named closing of blocks to prevent errors due to mismatched end
tokens. The adherence to strong typing allows detecting many common software errors (wrong parameters,
range violations, invalid references, mismatched types, etc.) either during compile-time, or otherwise during
run-time. As concurrency is part of the language specification, the compiler can in some cases detect
potential deadlocks.[17] Compilers also commonly check for misspelled identifiers, visibility of packages,
redundant declarations, etc. and can provide warnings and useful suggestions on how to fix the error.

Ada also supports run-time checks to protect against access to unallocated memory, buffer overflow errors,
range violations, off-by-one errors, array access errors, and other detectable bugs. These checks can be
disabled in the interest of runtime efficiency, but can often be compiled efficiently. It also includes facilities
to help program verification. For these reasons, Ada is widely used in critical systems, where any anomaly
might lead to very serious consequences, e.g., accidental death, injury or severe financial loss. Examples of
systems where Ada is used include avionics, air traffic control, railways, banking, military and space
technology.[18][19]

Ada's dynamic memory management is high-level and type-safe. Ada has no generic or untyped pointers;
nor does it implicitly declare any pointer type. Instead, all dynamic memory allocation and deallocation
must occur via explicitly declared access types. Each access type has an associated storage pool that
handles the low-level details of memory management; the programmer can either use the default storage
pool or define new ones (this is particularly relevant for Non-Uniform Memory Access). It is even possible
to declare several different access types that all designate the same type but use different storage pools.
Also, the language provides for accessibility checks, both at compile time and at run time, that ensures that
an access value cannot outlive the type of the object it points to.[20]

Though the semantics of the language allow automatic garbage collection of inaccessible objects, most
implementations do not support it by default, as it would cause unpredictable behaviour in real-time
systems. Ada does support a limited form of region-based memory management; also, creative use of
storage pools can provide for a limited form of automatic garbage collection, since destroying a storage
pool also destroys all the objects in the pool.

A double-dash ("--"), resembling an em dash, denotes comment text. Comments stop at end of line, to
prevent unclosed comments from accidentally voiding whole sections of source code. Disabling a whole
block of code now requires the prefixing of each line (or column) individually with "--". While clearly
denoting disabled code with a column of repeated "--" down the page this renders the experimental dis/re-
enablement of large blocks a more drawn out process.

The semicolon (";") is a statement terminator, and the null or no-operation statement is null;. A single ;
without a statement to terminate is not allowed.

Unlike most ISO standards, the Ada language definition (known as the Ada Reference Manual or ARM, or
sometimes the Language Reference Manual or LRM) is free content. Thus, it is a common reference for
Ada programmers, not only programmers implementing Ada compilers. Apart from the reference manual,
there is also an extensive rationale document which explains the language design and the use of various
language constructs. This document is also widely used by programmers. When the language was revised,
a new rationale document was written.
One notable free software tool that is used by many Ada programmers to aid them in writing Ada source
code is the GNAT Programming Studio, and GNAT which is part of the GNU Compiler Collection.

History
In the 1970s the US Department of Defense (DoD) became concerned by the number of different
programming languages being used for its embedded computer system projects, many of which were
obsolete or hardware-dependent, and none of which supported safe modular programming. In 1975, a
working group, the High Order Language Working Group (HOLWG), was formed with the intent to
reduce this number by finding or creating a programming language generally suitable for the department's
and the UK Ministry of Defence's requirements. After many iterations beginning with an original Straw
man proposal ([Link] the eventual programming
language was named Ada. The total number of high-level programming languages in use for such projects
fell from over 450 in 1983 to 37 by 1996.

HOLWG crafted the Steelman language requirements, a series of documents stating the requirements they
felt a programming language should satisfy. Many existing languages were formally reviewed, but the team
concluded in 1977 that no existing language met the specifications.

Requests for proposals for a new programming language were issued and
four contractors were hired to develop their proposals under the names of
Red (Intermetrics led by Benjamin Brosgol), Green (CII Honeywell Bull, led
by Jean Ichbiah), Blue (SofTech, led by John Goodenough)[21] and Yellow
(SRI International, led by Jay Spitzen). In April 1978, after public scrutiny,
the Red and Green proposals passed to the next phase. In May 1979, the
Green proposal, designed by Jean Ichbiah at CII Honeywell Bull, was
chosen and given the name Ada—after Augusta Ada, Countess of Lovelace.
This proposal was influenced by the language LIS that Ichbiah and his group
had developed in the 1970s. The preliminary Ada reference manual was
published in ACM SIGPLAN Notices in June 1979. The Military Standard
reference manual was approved on December 10, 1980 (Ada Lovelace's Augusta Ada King,
birthday), and given the number MIL-STD-1815 in honor of Ada Lovelace's Countess of Lovelace.
birth year. In 1981, C. A. R. Hoare took advantage of his Turing Award
speech to criticize Ada for being overly complex and hence unreliable,[22] but
subsequently seemed to recant in the foreword he wrote for an Ada textbook.[23]

Ada attracted much attention from the programming community as a whole during its early days. Its
backers and others predicted that it might become a dominant language for general purpose programming
and not only defense-related work.[24] Ichbiah publicly stated that within ten years, only two programming
languages would remain: Ada and Lisp.[25] Early Ada compilers struggled to implement the large, complex
language, and both compile-time and run-time performance tended to be slow and tools primitive.[24]
Compiler vendors expended most of their efforts in passing the massive, language-conformance-testing,
government-required Ada Compiler Validation Capability (ACVC) validation suite that was required in
another novel feature of the Ada language effort.[25] The Jargon File, a dictionary of computer hacker slang
originating in 1975–1983, notes in an entry on Ada ([Link]
that "it is precisely what one might expect given that kind of endorsement by fiat; designed by
committee...difficult to use, and overall a disastrous, multi-billion-dollar boondoggle...Ada
Lovelace...would almost certainly blanch at the use her name has been latterly put to; the kindest thing that
has been said about it is that there is probably a good small language screaming to get out from inside its
vast, elephantine bulk."
The first validated Ada implementation was the NYU Ada/Ed translator,[26] certified on April 11, 1983.
NYU Ada/Ed is implemented in the high-level set language SETL.[27] Several commercial companies
began offering Ada compilers and associated development tools, including Alsys, TeleSoft, DDC-I,
Advanced Computer Techniques, Tartan Laboratories, Irvine Compiler, TLD Systems, and Verdix.[28]
Computer manufacturers who had a significant business in the defense, aerospace, or related industries, also
offered Ada compilers and tools on their platforms; these included Concurrent Computer Corporation, Cray
Research, Inc., Harris Computer Systems, and Siemens Nixdorf Informationssysteme AG.[28]

In 1991, the US Department of Defense began to require the use of Ada (the Ada mandate) for all
software,[29] though exceptions to this rule were often granted.[24] The Department of Defense Ada
mandate was effectively removed in 1997, as the DoD began to embrace commercial off-the-shelf (COTS)
technology.[24] Similar requirements existed in other NATO countries: Ada was required for NATO
systems involving command and control and other functions, and Ada was the mandated or preferred
language for defense-related applications in countries such as Sweden, Germany, and Canada.[30]

By the late 1980s and early 1990s, Ada compilers had improved in performance, but there were still
barriers to fully exploiting Ada's abilities, including a tasking model that was different from what most real-
time programmers were used to.[25]

Because of Ada's safety-critical support features, it is now used not only for military applications, but also
in commercial projects where a software bug can have severe consequences, e.g., avionics and air traffic
control, commercial rockets such as the Ariane 4 and 5, satellites and other space systems, railway transport
and banking.[19] For example, the Airplane Information Management System, the fly-by-wire system
software in the Boeing 777, was written in Ada.[31][32] Developed by Honeywell Air Transport Systems in
collaboration with consultants from DDC-I, it became arguably the best-known of any Ada project, civilian
or military.[31][32] The Canadian Automated Air Traffic System was written in 1 million lines of Ada
(SLOC count). It featured advanced distributed processing, a distributed Ada database, and object-oriented
design. Ada is also used in other air traffic systems, e.g., the UK's next-generation Interim Future Area
Control Tools Support (iFACTS) air traffic control system is designed and implemented using SPARK
Ada.[33] It is also used in the French TVM in-cab signalling system on the TGV high-speed rail system,
and the metro suburban trains in Paris, London, Hong Kong and New York City.[19][34]

Standardization
Preliminary Ada can be found in ACM Sigplan Notices Vol 14, No 6, June 1979 ([Link]
f/10.1145/956650.956651).

Ada was first published in 1980 as an ANSI standard ANSI/MIL-STD 1815. As this very first version held
many errors and inconsistencies (see Summary of Ada Language Changes ([Link]
45/989791.989792)), the revised edition was published in 1983 as ANSI/MIL-STD 1815A. Without any
further changes, it became an ISO standard in 1987, ISO 8652:1987 ([Link]
tml). This version of the language is commonly known as Ada 83, from the date of its adoption by ANSI,
but is sometimes referred to also as Ada 87, from the date of its adoption by ISO. This is the Ada 83
Reference Manual ([Link] There is also a French
translation; DIN translated it into German as DIN 66268 in 1988.

Ada 95, the joint ISO/IEC/ANSI standard ISO/IEC 8652:1995 ([Link]


(see Ada 95 RM ([Link] was
published in February 1995, making it the first ISO standard object-oriented programming language. To
help with the standard revision and future acceptance, the US Air Force funded the development of the
GNAT Compiler. Presently, the GNAT Compiler is part of the GNU Compiler Collection.
Work has continued on improving and updating the technical content of the Ada language. A Technical
Corrigendum to Ada 95 was published in October 2001, ISO/IEC 8652:1995/Corr 1:2001 ([Link]
[Link]/standard/[Link]) (see Ada 95 RM with TC 1 ([Link]
[Link])), and a major Amendment, ISO/IEC 8652:1995/Amd 1:2007 ([Link]
[Link]) (see Ada 2005 RM ([Link]
ml)) was published on March 9, 2007, commonly known as Ada 2005 because work on the new standard
was finished that year.

At the Ada-Europe 2012 conference in Stockholm, the Ada Resource Association (ARA) and Ada-Europe
announced the completion of the design of the latest version of the Ada language and the submission of the
reference manual to the ISO/IEC JTC 1/SC 22/WG 9 of the International Organization for Standardization
(ISO) and the International Electrotechnical Commission (IEC) for approval. ISO/IEC 8652:2012 ([Link]
[Link]/standard/[Link]) (see Ada 2012 RM ([Link]
ds/12rm/html/[Link])) was published in December 2012, known as Ada 2012. A technical
corrigendum was published ISO/IEC 8652:2012/COR 1:2016 ([Link]
(see RM 2012 with TC 1 ([Link]

Despite the names Ada 83, 95 etc., legally there is only one Ada standard, the one of the last ISO/IEC
standard: with the acceptance of a new standard version, the previous one becomes withdrawn. The other
names are just informal ones referencing a certain edition.

Other related standards include ISO/IEC 8651-3:1988 Information processing systems—Computer


graphics—Graphical Kernel System (GKS) language bindings—Part 3: Ada.

Language constructs
Ada is an ALGOL-like programming language featuring control structures with reserved words such as if,
then, else, while, for, and so on. However, Ada also has many data structuring facilities and other
abstractions which were not included in the original ALGOL 60, such as type definitions, records, pointers,
enumerations. Such constructs were in part inherited from or inspired by Pascal.

"Hello, world!" in Ada

A common example of a language's syntax is the Hello world program: ([Link])

1 with Ada.Text_IO;
2 procedure Hello is
3 begin
4 Ada.Text_IO.Put_Line ("Hello, world!");
5 end Hello;

This program can be compiled by using the freely available open source compiler GNAT, by executing

gnatmake [Link]

Data types

Ada's type system is not based on a set of predefined primitive types but allows users to declare their own
types. This declaration in turn is not based on the internal representation of the type but on describing the
goal which should be achieved. This allows the compiler to determine a suitable memory size for the type,
and to check for violations of the type definition at compile time and run time (i.e., range violations, buffer
overruns, type consistency, etc.). Ada supports numerical types defined by a range, modulo types,
aggregate types (records and arrays), and enumeration types. Access types define a reference to an instance
of a specified type; untyped pointers are not permitted. Special types provided by the language are task
types and protected types.

For example, a date might be represented as:

1 type Day_type is range 1 .. 31;


2 type Month_type is range 1 .. 12;
3 type Year_type is range 1800 .. 2100;
4 type Hours is mod 24;
5 type Weekday is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);
6
7 type Date is
8 record
9 Day : Day_type;
10 Month : Month_type;
11 Year : Year_type;
12 end record;

Important to note: Day_type, Month_type, Year_type, Hours are incompatible types, meaning that for
instance the following expression is illegal:

1 Today: Day_type := 4;
2 Current_Month: Month_type := 10;
3 ... Today + Current_Month ... -- illegal

The predefined plus-operator can only add values of the same type, so the expression is illegal.

Types can be refined by declaring subtypes:

1 subtype Working_Hours is Hours range 0 .. 12; -- at most 12 Hours to work a


day
2 subtype Working_Day is Weekday range Monday .. Friday; -- Days to work
3
4 Work_Load: constant array(Working_Day) of Working_Hours -- implicit type declaration
5 := (Friday => 6, Monday => 4, others => 10); -- lookup table for working
hours with initialization

Types can have modifiers such as limited, abstract, private etc. Private types do not show their inner
structure; objects of limited types cannot be copied.[35] Ada 95 adds further features for object-oriented
extension of types.

Control structures

Ada is a structured programming language, meaning that the flow of control is structured into standard
statements. All standard constructs and deep-level early exit are supported, so the use of the also supported
"go to" commands is seldom needed.

1 -- while a is not equal to b, loop.


2 while a /= b loop
3 Ada.Text_IO.Put_Line ("Waiting");
4 end loop;
5
6 if a > b then
7 Ada.Text_IO.Put_Line ("Condition met");
8 else
9 Ada.Text_IO.Put_Line ("Condition not met");
10 end if;
11
12 for i in 1 .. 10 loop
13 Ada.Text_IO.Put ("Iteration: ");
14 Ada.Text_IO.Put (i);
15 Ada.Text_IO.Put_Line;
16 end loop;
17
18 loop
19 a := a + 1;
20 exit when a = 10;
21 end loop;
22
23 case i is
24 when 0 => Ada.Text_IO.Put ("zero");
25 when 1 => Ada.Text_IO.Put ("one");
26 when 2 => Ada.Text_IO.Put ("two");
27 -- case statements have to cover all possible cases:
28 when others => Ada.Text_IO.Put ("none of the above");
29 end case;
30
31 for aWeekday in Weekday'Range loop -- loop over an enumeration
32 Put_Line ( Weekday'Image(aWeekday) ); -- output string representation of an
enumeration
33 if aWeekday in Working_Day then -- check of a subtype of an enumeration
34 Put_Line ( " to work for " &
35 Working_Hours'Image (Work_Load(aWeekday)) ); -- access into a lookup table
36 end if;
37 end loop;

Packages, procedures and functions

Among the parts of an Ada program are packages, procedures and functions.

Example: Package specification ([Link])

1 package Example is
2 type Number is range 1 .. 11;
3 procedure Print_and_Increment (j: in out Number);
4 end Example;

Package body ([Link])

1 with Ada.Text_IO;
2 package body Example is
3
4 i : Number := Number'First;
5
6 procedure Print_and_Increment (j: in out Number) is
7
8 function Next (k: in Number) return Number is
9 begin
10 return k + 1;
11 end Next;
12
13 begin
14 Ada.Text_IO.Put_Line ( "The total is: " & Number'Image(j) );
15 j := Next (j);
16 end Print_and_Increment;
17
18 -- package initialization executed when the package is elaborated
19 begin
20 while i < Number'Last loop
21 Print_and_Increment (i);
22 end loop;
23 end Example;

This program can be compiled, e.g., by using the freely available open-source compiler GNAT, by
executing

gnatmake -z [Link]

Packages, procedures and functions can nest to any depth, and each can also be the logical outermost
block.

Each package, procedure or function can have its own declarations of constants, types, variables, and other
procedures, functions and packages, which can be declared in any order.

Concurrency

Ada has language support for task-based concurrency. The fundamental concurrent unit in Ada is a task,
which is a built-in limited type. Tasks are specified in two parts – the task declaration defines the task
interface (similar to a type declaration), the task body specifies the implementation of the task. Depending
on the implementation, Ada tasks are either mapped to operating system threads or processes, or are
scheduled internally by the Ada runtime.

Tasks can have entries for synchronisation (a form of synchronous message passing). Task entries are
declared in the task specification. Each task entry can have one or more accept statements within the task
body. If the control flow of the task reaches an accept statement, the task is blocked until the corresponding
entry is called by another task (similarly, a calling task is blocked until the called task reaches the
corresponding accept statement). Task entries can have parameters similar to procedures, allowing tasks to
synchronously exchange data. In conjunction with select statements it is possible to define guards on accept
statements (similar to Dijkstra's guarded commands).

Ada also offers protected objects for mutual exclusion. Protected objects are a monitor-like construct, but
use guards instead of conditional variables for signaling (similar to conditional critical regions). Protected
objects combine the data encapsulation and safe mutual exclusion from monitors, and entry guards from
conditional critical regions. The main advantage over classical monitors is that conditional variables are not
required for signaling, avoiding potential deadlocks due to incorrect locking semantics. Like tasks, the
protected object is a built-in limited type, and it also has a declaration part and a body.

A protected object consists of encapsulated private data (which can only be accessed from within the
protected object), and procedures, functions and entries which are guaranteed to be mutually exclusive
(with the only exception of functions, which are required to be side effect free and can therefore run
concurrently with other functions). A task calling a protected object is blocked if another task is currently
executing inside the same protected object, and released when this other task leaves the protected object.
Blocked tasks are queued on the protected object ordered by time of arrival.

Protected object entries are similar to procedures, but additionally have guards. If a guard evaluates to false,
a calling task is blocked and added to the queue of that entry; now another task can be admitted to the
protected object, as no task is currently executing inside the protected object. Guards are re-evaluated
whenever a task leaves the protected object, as this is the only time when the evaluation of guards can have
changed.
Calls to entries can be requeued to other entries with the same signature. A task that is requeued is blocked
and added to the queue of the target entry; this means that the protected object is released and allows
admission of another task.

The select statement in Ada can be used to implement non-blocking entry calls and accepts, non-
deterministic selection of entries (also with guards), time-outs and aborts.

The following example illustrates some concepts of concurrent programming in Ada.

1 with Ada.Text_IO; use Ada.Text_IO;


2
3 procedure Traffic is
4
5 type Airplane_ID is range 1..10; -- 10 airplanes
6
7 task type Airplane (ID: Airplane_ID); -- task representing airplanes, with ID
as initialisation parameter
8 type Airplane_Access is access Airplane; -- reference type to Airplane
9
10 protected type Runway is -- the shared runway (protected to allow
concurrent access)
11 entry Assign_Aircraft (ID: Airplane_ID); -- all entries are guaranteed mutually
exclusive
12 entry Cleared_Runway (ID: Airplane_ID);
13 entry Wait_For_Clear;
14 private
15 Clear: Boolean := True; -- protected private data - generally
more than only a flag...
16 end Runway;
17 type Runway_Access is access all Runway;
18
19 -- the air traffic controller task takes requests for takeoff and landing
20 task type Controller (My_Runway: Runway_Access) is
21 -- task entries for synchronous message passing
22 entry Request_Takeoff (ID: in Airplane_ID; Takeoff: out Runway_Access);
23 entry Request_Approach(ID: in Airplane_ID; Approach: out Runway_Access);
24 end Controller;
25
26 -- allocation of instances
27 Runway1 : aliased Runway; -- instantiate a runway
28 Controller1: Controller (Runway1'Access); -- and a controller to manage it
29
30 ------ the implementations of the above types ------
31 protected body Runway is
32 entry Assign_Aircraft (ID: Airplane_ID)
33 when Clear is -- the entry guard - calling tasks are blocked until the condition is
true
34 begin
35 Clear := False;
36 Put_Line (Airplane_ID'Image (ID) & " on runway ");
37 end;
38
39 entry Cleared_Runway (ID: Airplane_ID)
40 when not Clear is
41 begin
42 Clear := True;
43 Put_Line (Airplane_ID'Image (ID) & " cleared runway ");
44 end;
45
46 entry Wait_For_Clear
47 when Clear is
48 begin
49 null; -- no need to do anything here - a task can only enter if "Clear" is
true
50 end;
51 end Runway;
52
53 task body Controller is
54 begin
55 loop
56 My_Runway.Wait_For_Clear; -- wait until runway is available (blocking call)
57 select -- wait for two types of requests (whichever is
runnable first)
58 when Request_Approach'count = 0 => -- guard statement - only accept if there
are no tasks queuing on Request_Approach
59 accept Request_Takeoff (ID: in Airplane_ID; Takeoff: out Runway_Access)
60 do -- start of synchronized part
61 My_Runway.Assign_Aircraft (ID); -- reserve runway (potentially blocking
call if protected object busy or entry guard false)
62 Takeoff := My_Runway; -- assign "out" parameter value to tell
airplane which runway
63 end Request_Takeoff; -- end of the synchronised part
64 or
65 accept Request_Approach (ID: in Airplane_ID; Approach: out Runway_Access) do
66 My_Runway.Assign_Aircraft (ID);
67 Approach := My_Runway;
68 end Request_Approach;
69 or -- terminate if no tasks left who could call
70 terminate;
71 end select;
72 end loop;
73 end;
74
75 task body Airplane is
76 Rwy : Runway_Access;
77 begin
78 Controller1.Request_Takeoff (ID, Rwy); -- This call blocks until Controller task
accepts and completes the accept block
79 Put_Line (Airplane_ID'Image (ID) & " taking off...");
80 delay 2.0;
81 Rwy.Cleared_Runway (ID); -- call will not block as "Clear" in Rwy is
now false and no other tasks should be inside protected object
82 delay 5.0; -- fly around a bit...
83 loop
84 select -- try to request a runway
85 Controller1.Request_Approach (ID, Rwy); -- this is a blocking call - will run
on controller reaching accept block and return on completion
86 exit; -- if call returned we're clear for landing - leave select block and
proceed...
87 or
88 delay 3.0; -- timeout - if no answer in 3 seconds, do something else
(everything in following block)
89 Put_Line (Airplane_ID'Image (ID) & " in holding pattern"); -- simply print
a message
90 end select;
91 end loop;
92 delay 4.0; -- do landing approach...
93 Put_Line (Airplane_ID'Image (ID) & " touched down!");
94 Rwy.Cleared_Runway (ID); -- notify runway that we're done here.
95 end;
96
97 New_Airplane: Airplane_Access;
98
99 begin
100 for I in Airplane_ID'Range loop -- create a few airplane tasks
101 New_Airplane := new Airplane (I); -- will start running directly after creation
102 delay 4.0;
103 end loop;
104 end Traffic;

Pragmas

A pragma is a compiler directive that conveys information to the compiler to allow specific manipulating of
compiled output.[36] Certain pragmas are built into the language,[37] while others are implementation-
specific.
Examples of common usage of compiler pragmas would be to disable certain features, such as run-time
type checking or array subscript boundary checking, or to instruct the compiler to insert object code instead
of a function call (as C/C++ does with inline functions).

Generics

Ada has had generics since it was first designed in 1977–1980. The standard library uses generics to
provide many services. Ada 2005 adds a comprehensive generic container library to the standard library,
which was inspired by C++'s standard template library.

A generic unit is a package or a subprogram that takes one or more generic formal parameters.

A generic formal parameter is a value, a variable, a constant, a type, a subprogram, or even an instance of
another, designated, generic unit. For generic formal types, the syntax distinguishes between discrete,
floating-point, fixed-point, access (pointer) types, etc. Some formal parameters can have default values.

To instantiate a generic unit, the programmer passes actual parameters for each formal. The generic
instance then behaves just like any other unit. It is possible to instantiate generic units at run-time, for
example inside a loop.

See also
Computer
programming
portal

APSE – a specification for a programming environment to support software development in


Ada
Ravenscar profile – a subset of the Ada tasking features designed for safety-critical hard
real-time computing
SPARK (programming language) – a programming language consisting of a highly restricted
subset of Ada, annotated with meta-information describing desired component behavior and
individual runtime requirements

References
1. "Ada2012 Rationale" ([Link]
_Introducion.pdf) (PDF). [Link]. Archived ([Link]
40/[Link]
(PDF) from the original on 18 April 2016. Retrieved 5 May 2018.
2. "Technical Corrigendum for Ada 2012 published by ISO" ([Link]
nical-corrigendum-for-ada-2012-published-by-iso/). Ada Resource Association. 2016-01-29.
Retrieved 2016-02-23.
3. "Consolidated Ada 2012 Language Reference Manual" ([Link]
03001815/[Link] Ada Conformity
Assessment Authority. Archived from the original ([Link]
w_tc1.html) on 2016-03-03. Retrieved 2016-02-23.
4. Free download: [Link]
5. "PTC ObjectAda" ([Link] [Link]. Retrieved
2014-01-27.
6. "MapuSoft Ada-C/C++ changer" ([Link] 16 April
2019.
7. "AdaMagic with C Intermediate certificate" ([Link]
8. Ada Rationale, 1986, pp. 23, 70, 110–114, 137, 165, 236
9. "Chapel spec (Acknowledgements)" ([Link] (PDF). Cray
Inc. 2015-10-01. Archived ([Link]
spec/[Link]) (PDF) from the original on 2022-10-09. Retrieved 2016-01-14.
10. "Drago" ([Link]
Drago/). Archived from the original ([Link] on 2020-09-
14. Retrieved 2018-08-06.
11. "Griffin" ([Link]
12. "SPARforte" ([Link]
13. Ganssle, Jack (2013-05-29). "Ada Resource Association – News and resource for the Ada
programming language" ([Link] [Link]. Retrieved 2013-06-14.
14. "ISO/IEC 8652:2012 Information technology – Programming languages – Ada" ([Link]
[Link]/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=61507). International
Organization for Standardization. Retrieved 2012-12-23.
15. "The Ada Programming Language" ([Link]
[Link]/CIS/[Link]/cis400/ada/[Link]). University of Mich.
Archived from the original ([Link]
[Link]) on 2016-05-22. Retrieved 27 May 2016.
16. Fuegi, J; Francis, J (2003). "Lovelace & Babbage and the creation of the 1843 'notes' ". IEEE
Annals of the History of Computing. 25 (4): 16–26. doi:10.1109/MAHC.2003.1253887 (http
s://[Link]/10.1109%2FMAHC.2003.1253887). S2CID 40077111 ([Link]
[Link]/CorpusID:40077111).
17. "Concurrency - Chapter 6 - Ada 95 QUALITY AND STYLE Guide" ([Link]
ources/add_content/docs/95style/html/sec_6/). [Link]. Retrieved November 5, 2021.
18. Taft, S. Tucker; Olsen, Florence (1999-06-30). "Ada helps churn out less-buggy code" (http://
[Link]/Articles/1999/06/30/[Link]). Government
Computer News. pp. 2–3. Retrieved 2010-09-14.
19. Feldman, Michael. "Who's using Ada?" ([Link]
[Link]#Banking_and_Financial_Systems). SIGAda Education Working Group.
20. no safe dynamic memory management in ADA ([Link]
M&t=419), in: Writing Linux Kernel Modules in Safe Rust - Geoffrey Thomas & Alex Gaynor ,
The Linux Foundation, 2019-10-02
21. "John Goodenough | SEI Staff Profile" ([Link]
[Link]. Retrieved 2014-01-27.
22. C.A.R., Hoare (1981). "The Emperor's Old Clothes" ([Link]
11/bib/[Link]) (PDF). Communications of the ACM. Association for Computing
Machinery. 24 (2): 75–83. doi:10.1145/358549.358561 ([Link]
58561). S2CID 97895 ([Link] Archived ([Link]
[Link]/archive/20221009/[Link]
[Link]) (PDF) from the original on 2022-10-09.
23. Watt, D.A.; Wichmann, B.A.; Findlay, W. (1987). Ada: Language and Methodology. Prentice-
Hall.
24. Sward, Ricky E. (November 2010). "The rise, fall and persistence of Ada". SIGAda '10:
Proceedings of the ACM SIGAda annual international conference on SIGAda ([Link]
rg/[Link]?id=1879063.1879081&coll=DL&dl=GUIDE&CFID=551420221&CFTOKEN=
60383966). pp. 71–74. doi:10.1145/1879063.1879081 ([Link]
1879081).
25. Rosen, J-P. (August 2009). "The Ada Paradox(es)". Ada Letters. ACM SIGAda. 24 (2): 28–
35. doi:10.1145/1620593.1620597 ([Link]
S2CID 608405 ([Link]
26. SofTech Inc. (1983-04-11). "Ada Compiler Validation Summary Report: NYU Ada/ED,
Version 19.7 V-001" ([Link]
i?verb=getRecord&metadataPrefix=html&identifier=ADA136759). Waltham, MA. Archived
from the original ([Link]
ADA136759) on 2012-03-12. Retrieved 2010-12-16.
27. Dewar, Robert B. K.; Fisher, Gerald A. Jr.; Schonberg, Edmond; Froelich, Robert; Bryant,
Stephen; Goss, Clinton F.; Burke, Michael (November 1980). "The NYU Ada Translator and
Interpreter". ACM SIGPLAN Notices – Proceedings of the ACM-SIGPLAN Symposium on
the Ada Programming Language. 15 (11): 194–201. doi:10.1145/948632.948659 ([Link]
org/10.1145%2F948632.948659). ISBN 0-89791-030-3. S2CID 10586359 ([Link]
[Link]/CorpusID:10586359).
28. "Ada Validated Compilers List". Ada Information Clearinghouse. July 1, 1992. pp. 1–36.
29. Ada Information Clearinghouse (1983-04-11). "The Congressional Ada Mandate" ([Link]
[Link]/web/20160304073005/[Link]
Archived from the original ([Link] on 2016-03-
04. Retrieved 2015-06-07.
30. Babiak, Nicholas J. (1989). Ada, the New DoD Weapon System Computer Language –
Panacea or Calamity ([Link] (PDF). Air University
(United States Air Force). pp. 39–40. Archived ([Link]
4/[Link] (PDF) from the original on December 15,
2019.
31. Rehmer, Karl (2009). "The HADS Team". In Stellman, Andrew; Greene, Jennifer (eds.).
Beautiful Teams: Inspiring and Cautionary Tales from Veteran Team Leaders. Sebastopol,
California: O'Reilly. pp. 299–312.
32. Wolfe, Alexander (October 2004). "There's Still Some Life Left in Ada" ([Link]
[Link]?id=1035608). ACM Queue. 2 (7): 28–31. doi:10.1145/1035594.1035608 ([Link]
[Link]/10.1145%2F1035594.1035608).
33. AdaCore. "GNAT Pro Chosen for UK's Next Generation ATC System" ([Link]
g/web/20101224163518/[Link]
k-next-generation/). Archived from the original ([Link]
gnat-pro-chosen-for-uk-next-generation/) on 2010-12-24. Retrieved 2011-03-01.
34. AdaCore. "Look Who's Using Ada" ([Link]
[Link]/home/ada_answers/lookwho). Archived from the original ([Link]
[Link]/home/ada_answers/lookwho/) on 2010-12-24. Retrieved 2011-03-01.
35. "Ada Syntax Card" ([Link]
kreferences/QRC/Ada%20Syntax%[Link]) (PDF). Archived from the original ([Link]
[Link]/quickreferences/QRC/Ada%20Syntax%[Link]) (PDF) on 6 July 2011.
Retrieved 28 February 2011.
36. "Ada 83 LRM, Sec 2.8: Pragmas" ([Link]
tml#2.8). [Link]. Retrieved 2014-01-27.
37. "Ada 83 LRM, Appendix/Annex B: Predefined Language Pragmas" ([Link]
web/20120206005541/[Link]
[Link]. Archived from the original ([Link]
[Link]) on 2012-02-06. Retrieved 2014-01-27.

International standards
ISO/IEC 8652: Information technology—Programming languages—Ada
ISO/IEC 15291: Information technology—Programming languages—Ada Semantic Interface
Specification (ASIS)
ISO/IEC 18009: Information technology—Programming languages—Ada: Conformity
assessment of a language processor (ACATS)
IEEE Standard 1003.5b-1996, the POSIX Ada binding
Ada Language Mapping Specification ([Link]
[Link]/technology/documents/formal/ada_language_mapping.htm), the CORBA
interface description language (IDL) to Ada mapping

Rationale

These documents have been published in various forms, including print.

Ichbiah, Jean D.; Barnes, John G. P.; Firth, Robert J.; Woodger, Mike (1986), Rationale for
the Design of the Ada Programming Language ([Link]
3/[Link] archived from the original (htt
p://[Link]/standards/83rat/html/[Link]) on 2007-02-02 Also available
[Link] ([Link] pdf
Barnes, John G. P. (1995), Ada 95 rationale: the language: the standard libraries ([Link]
[Link]/resources/add_content/standards/95rat/rat95html/[Link])
Barnes, John (2006) [2005], Rationale for Ada 2005 ([Link]
ml/[Link])

Books
Booch, Grady (1987). Software Engineering with Ada ([Link]
ineer0002booc). California: The Benjamin/Cummings Publishing Company. ISBN 0-8053-
0604-8.
Skansholm, Jan (1996). Ada 95 From the Beginning. Addison-Wesley. ISBN 0-201-40376-5.
Gilpin, Geoff (1985). Ada: A Guided Tour and Tutorial. Prentice hall. ISBN 978-0-13-004045-
9.
Barnes, John (2006). Programming in Ada 2005. Addison-Wesley. ISBN 0-321-34078-7.
Barnes, John (1991). Programming in Ada plus Language Reference Manual. Addison-
Wesley. ISBN 0-201-56539-0.
Barnes, John (1998). Programming in Ada 95. Addison-Wesley. ISBN 0-201-34293-6.
Barnes, John (1997). High Integrity Ada: The SPARK Approach. Addison-Wesley. ISBN 0-
201-17517-7.
Barnes, John (2003). High Integrity Software: The SPARK Approach to Safety and Security.
Addison-Wesley. ISBN 0-321-13616-0.
Beidler, John (1997). Data Structures and Algorithms: An Object-Oriented Approach Using
Ada 95. Springer-Verlag. ISBN 0-387-94834-1.
Gonzalez, Dean W. (1991). Ada Programmer's Handbook. Benjamin-Cummings Publishing
Company. ISBN 0-8053-2529-8.
Ben-Ari, M. (1998). Ada for Software Engineers. John Wiley & Sons. ISBN 0-471-97912-0.
Cohen, Norman (1996). Ada as a Second Language. McGraw-Hill
Science/Engineering/Math. ISBN 0-07-011607-5.
Burns, Alan; Wellings, Andy (2001). Real-Time Systems and Programming Languages. Ada
95, Real-Time Java and Real-Time POSIX. Addison-Wesley. ISBN 0-201-72988-1.
Burns, Alan; Wellings, Andy (1995). Concurrency in Ada. Cambridge University Press.
ISBN 0-521-62911-X.
Atkinson, Colin (1991). Object-Oriented Reuse, Concurrency and Distribution: An Ada-
Based Approach. Addison-Wesley. ISBN 0-201-56527-7.
Booch, Grady; Bryan, Doug (1994). Software Engineering with Ada. Addison-Wesley.
ISBN 0-8053-0608-0.
Jones, Do-While (1989). Ada in Action: With Practical Programming Examples. John Wiley
& Sons. ISBN 0-471-60708-8.
Stubbs, Daniel; Webre, Neil W. (1993). Data Structures with Abstract Data Types and Ada.
Brooks Cole. ISBN 0-534-14448-9.
Ledru, Pascal (December 1998). Distributed Programming in Ada with Protected Objects.
[Link]. ISBN 1-58112-034-6.
Culwin, Fintan (1997). Ada, a Developmental Approach. Prentice Hall. ISBN 0-13-264680-3.
English, John; Culwin, Fintan (January 1997). Ada 95 the Craft of Object-Oriented
Programming. Prentice Hall. ISBN 0-13-230350-7.
Musser, David R.; Stepanov, Alexander (24 October 1989). The Ada Generic Library: Linear
List Processing Packages. Springer-Verlag. ISBN 0-387-97133-5.
Feldman, Michael B. (1997). Software Construction and Data Structures with Ada 95.
Addison-Wesley. ISBN 0-201-88795-9.
Johnston, Simon (1997). Ada 95 for C and C++ Programmers. Addison-Wesley. ISBN 0-201-
40363-3.
Feldman, Michael B.; Koffman, Elliot B. (1992–1993). Ada: Problem Solving and Program
Design. Addison-Wesley. ISBN 0-201-52279-9. 795 pages.
Feldman, Michael B.; Koffman, Elliot B. (1999). Ada 95. Addison-Wesley. ISBN 0-201-
36123-X.
Dale, Nell B.; Weems, Chip; McCormick, John (August 1996). Programming and Problem
Solving with Ada 95. Jones & Bartlett Publishers. ISBN 0-7637-0293-5.
Dale, Nell B.; McCormick, John (2007). Ada Plus Data Structures: An Object-Oriented
Approach, 2nd edition. Jones & Bartlett Publishers. ISBN 978-0-7637-3794-8.
Krell, Bruce C. (1992). Developing With Ada: Life-Cycle Methods. Bantam Dell Pub Group.
ISBN 0-553-09102-6.
Bishop, Judy (10 May 1990). Distributed Ada: Developments and Experiences. Cambridge
University Press. ISBN 0-521-39251-9.
Sanden, Bo (1994). Software Systems Construction With Examples in Ada. Prentice Hall.
ISBN 0-13-030834-X.
Hillam, Bruce (1994). Introduction to Abstract Data Types Using Ada. Prentice Hall. ISBN 0-
13-045949-6.
Rudd, David (1994). Introduction to Software Design and Development With Ada. Brooks
Cole. ISBN 0-314-02829-3.
Pyle, Ian C. (1991). Developing Safety Systems: A Guide Using Ada. Prentice Hall. ISBN 0-
13-204298-3.
Baker, Louis (1989). Artificial Intelligence With Ada. McGraw-Hill. ISBN 0-07-003350-1.
Burns, Alan; Wellings, Andy (1995). HRT-HOOD: A Structured Design Method for Hard Real-
Time Ada Systems. North-Holland. ISBN 0-444-82164-3.
Savitch, Walter; Peterson, Charles (1992). Ada: An Introduction to the Art and Science of
Programming. Benjamin-Cummings Publishing Company. ISBN 0-8053-7070-6.
Weiss, Mark Allen (1993). Data Structures and Algorithm Analysis in Ada. Benjamin-
Cummings Publishing Company. ISBN 0-8053-9055-3.
Ledgard, Henry (1983). Ada: An Introduction (second ed.). Springer-Verlag. ISBN 0-387-
90814-5.
Bjørner, Dines; Oest, Ole N., eds. (1980). Towards a Formal Description of Ada. London:
Springer-Verlag. ISBN 3-540-10283-3.

Archives
Ada Programming Language Materials, 1981–1990 ([Link] Charles
Babbage Institute, University of Minnesota. Includes literature on software products
designed for the Ada language; U.S. government publications, including Ada 9X project
reports, technical reports, working papers, newsletters; and user group information.

External links
Ada - C/C++ changer - MapuSoft ([Link]
DOD Ada programming language (ANSI/MIL STD 1815A-1983) specification ([Link]
[Link]/[Link]?ident_number=37152)
JTC1/SC22/WG9 ISO home of Ada Standards ([Link]
Ada (programming language) ([Link] at
Curlie

Retrieved from "[Link]

This page was last edited on 18 December 2022, at 07:26 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 3.0; additional terms may apply. By
using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the
Wikimedia Foundation, Inc., a non-profit organization.

You might also like