411 REFERENCE · Wikibooks
Ada Programming/Ada 2005
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
2005
__TOC__
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 83 and Ada 95, the informal name Ada 2005 is generally agreed on). For the rationale and a more detailed (and very technical) description, see the Amendment 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 Software compilers:
GNAT GPL Edition
GCC 4.1
GNAT Pro 6.0.2 (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.
Language features
Character set
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.Numerics will be extended with a new constant:
π : constant := Pi;
This is not a new idea — GNAT always had the -gnatic compiler option to specify the character set . But now this idea has become standard, so all Ada compilers will need to support Unicode 4.0 for identifiers — as the new standard requires.
See also:
285 Support for 16-bit and 32-bit characters
388 Add Greek pi to Ada.Numerics
Interfaces
Interfaces allow for a limited form of multiple inheritance similar to Java and C#.
You find a full description here: Ada Programming/OO.
See also:
251 Abstract Interfaces to provide multiple inheritance
345 Protected and task interfaces
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#Union.
See also:
216 Unchecked unions -- variant records with no run-time discriminant
B 3 3 Pragma Unchecked_Union
With
The with statement got a massive upgrade. First there is the new limited with which allows two packages to with each other. Then there is private with to make a package only visible inside the private part of the specification.
See also:
217 Limited With Clauses 6
262 Access to private units in the private part
Access types
Not null access
An access type definition can specify that the access type can never be null.
See Ada Programming/Types/access#Null exclusions.
See also: 231 Access-to-constant parameters and null-excluding access subtypes
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.
function "=" (Left, Right : universal_access) return Boolean;
function "/="(Left, Right : universal_access) return Boolean;
See Ada Programming/Types/access#Anonymous access.
See also:
230 Generalized use of anonymous access types
385 Stand-alone objects of anonymous access types
318 Limited and anonymous access return types 2
Language library
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 Containers.
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 302 Container library 3 has now been transformed into
A 18 Containers.
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 302 AI Text 3 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 Containers) which you can find at
tigris.
In Ada Programming/Containers 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 Collection has a few publications available.
Scan Filesystem Directories and Environment Variables
See also:
248 Directory Operations
370 Environment variables
Numerics
Besides the new constant of package Ada.Numerics (see Character Set above), the most important addition are the packages to operate with vectors and matrices.
See also:
388 Add Greek pi (π) to Ada.Numerics
296 Vector and matrix operations
(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.)
Real-Time and High Integrity Systems
See also:
297 Timing events
307 Execution-Time Clocks
354 Group execution-time budgets
266 Task termination procedure 2
386 Further functions returning Time_Span values
Ravenscar profile
See also:
249 Ravenscar profile for high-integrity systems
305 New pragma and additional restriction identifiers for real-time systems
347 Title of Annex H
265 Partition Elaboration Policy for High-Integrity Systems
New scheduling policies
See also:
355 Priority Specific Dispatching including Round Robin
357 Support for Deadlines and Earliest Deadline First Scheduling
298 Non-Preemptive Dispatching
Dynamic priorities for protected objects
See also: 327 Dynamic ceiling priorities
Summary of what's new
New keywords
Added 3 keywords (72 total)
interface
overriding
synchronized
New pragmas
Added 11 pragmas:
Assert
Assertion_Policy
Detect_Blocking
No_Return
Partition_Elaboration_Policy
Preelaborable_Initialization
Priority_Specific_Dispatching
Profile
Relative_Deadline
Unchecked_Union
Unsuppress
New attributes
Added 7 attributes:
Machine_Rounding
Mod
Priority
Stream_Size
Wide_Wide_Image
Wide_Wide_Value
Wide_Wide_Width
New packages
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)
Ada.Strings.Unbounded.Hash (generic function)
Ada.Strings.Wide_Hash (generic function)
Ada.Strings.Wide_Fixed.Wide_Hash (generic function)
Ada.Strings.Wide_Bounded.Wide_Hash (generic function)
Ada.Strings.Wide_Unbounded.Wide_Hash (generic function)
Ada.Strings.Wide_Wide_Hash (generic function)
Ada.Strings.Wide_Wide_Fixed.Wide_Wide_Hash (generic function)
Ada.Strings.Wide_Wide_Bounded.Wide_Wide_Hash (generic function)
Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Hash (generic function)
Time operations:
Ada.Calendar.Time_Zones
Ada.Calendar.Arithmetic
Ada.Calendar.Formatting
Tagged types:
Ada.Tags.Generic_Dispatching_Constructor (generic function)
Text packages:
Ada.Complex_Text_IO
Ada.Text_IO.Bounded_IO
Ada.Text_IO.Unbounded_IO
Ada.Wide_Text_IO.Wide_Bounded_IO
Ada.Wide_Text_IO.Wide_Unbounded_IO
Ada.Wide_Characters
Ada.Wide_Wide_Characters
Wide_Wide_Character packages:
Ada.Strings.Wide_Wide_Bounded
Ada.Strings.Wide_Wide_Fixed
Ada.Strings.Wide_Wide_Maps
Ada.Strings.Wide_Wide_Maps.Wide_Wide_Constants
Ada.Strings.Wide_Wide_Unbounded
Ada.Wide_Wide_Text_IO
Ada.Wide_Wide_Text_IO.Complex_IO
Ada.Wide_Wide_Text_IO.Editing
Ada.Wide_Wide_Text_IO.Text_Streams
Ada.Wide_Wide_Text_IO.Wide_Wide_Bounded_IO
Ada.Wide_Wide_Text_IO.Wide_Wide_Unbounded_IO
Execution-time clocks:
Ada.Execution_Time
Ada.Execution_Time.Timers
Ada.Execution_Time.Group_Budgets
Dispatching:
Ada.Dispatching
Ada.Dispatching.EDF
Ada.Dispatching.Round_Robin
Timing events:
Ada.Real_Time.Timing_Events
Task termination procedures:
Ada.Task_Termination
See also
Wikibook
Ada Programming/Ada 83
Ada Programming/Ada 95
Ada Programming/Ada 2012
Ada Programming/Object Orientation
Ada Programming/Types/access
Ada Programming/Keywords
Ada Programming/Keywords/and
Ada Programming/Keywords/interface
Ada Programming/Attributes
Ada Programming/Pragmas
Ada Programming/Pragmas/Restrictions
Ada Programming/Libraries/Ada.Containers
Ada Programming/Libraries/Ada.Directories
Pages in the category Ada 2005
:Ada Programming/Ada 2005 feature
External links
Papers and presentations
Ada 2005: Putting it all together (SIGAda 2004 presentation)
GNAT and Ada 2005 (SIGAda 2004 paper)
An invitation to Ada 2005, and the presentation of this paper at Ada-Europe 2004
Rationale
Rationale for Ada 2005 by John Barnes:
Introduction
Object Oriented Model
Access Types
Structure and Visibility
Tasking and Real-Time
Exceptions, Generics, Etc.
Predefined Library
Containers
Epilogue
References
Index
Available as a single document for printing.
Language Requirements
Instructions to the Ada Rapporteur Group from SC22/WG9 for Preparation of the Amendment to ISO/IEC 8652 (10 October 2002), and a presentation of this document at SIGAda 2002
Ada Reference Manual
Ada Reference Manual, ISO/IEC 8652:1995(E) with COR.1:2001 and AMD.1:2007
Annotated Ada Reference Manual, ISO/IEC 8652:1995(E) with COR.1:2001 and AMD.1:2007 (colored diffs)
List of Ada Amendment drafts
Ada Issues
Amendment 200Y
387 Introduction to Amendment
284 New reserved words 2
252 Object.Operation notation
218 Accidental overloading when overriding 3
348 Null procedures
287 Limited aggregates allowed
326 Incomplete types
317 Partial parameter lists for formal packages
376 Interfaces.C works for C++ as well
368 Restrictions for obsolescent features
381 New Restrictions identifier No_Dependence
224 pragma Unsuppress
161 Default-initialized objects
361 Raise with message
286 Assert pragma
328 Preinstantiations of Complex_IO
301 Operations on language-defined string types
340 Mod attribute
364 Fixed-point multiply/divide
267 Fast float-to-integer conversions
321 Definition of dispatching policies
329 pragma No_Return -- procedures that never return
362 Some predefined packages should be recategorized
351 Time operations
427 Default parameters and Calendar operations
270 Stream item size control
Ada 2005
*Ada 2005
*Ada 2005