Information technology — Programming languages — Ada

ISO/IEC 8652:2012 specifies the form and meaning of programs written in the programming language Ada. Its purpose is to promote the portability of Ada programs to a variety of computing systems. This third edition of ISO/IEC 8652 focuses on improvements in those user domains where safety and criticality are prime concerns. It enhances the functionality of containers, improves the ability to write and enforce contracts for Ada entities (for instance, via preconditions), and adds to the capabilities of Ada to perform on multicore and multithreaded architectures. Ada is designed to support the construction of long‐lived, highly reliable software systems. The language includes facilities to define packages of related types, objects, and operations. The packages may be parameterized and the types may be extended to support the construction of libraries of reusable, adaptable software components. The operations may be implemented as subprograms using conventional sequential control structures, or as entries that include synchronization of concurrent threads of control as part of their invocation. Ada supports object‐oriented programming by providing classes and interfaces, inheritance, polymorphism of variables and methods, and generic units. The language treats modularity in the physical sense as well, with a facility to support separate compilation. The language provides rich support for real‐time, concurrent programming, and includes facilities for multicore and multiprocessor programming. Errors can be signaled as exceptions and handled explicitly. The language also covers systems programming; this requires precise control over the representation of data and access to system‐dependent properties. Finally, a predefined environment of standard packages is provided, including facilities for, among others, input‐output, string manipulation, numeric elementary functions, random number generation, and definition and use of containers. Foremost in the design of Ada is the intent to increase the reliability of programs by compiletime checking and rejection of unsafe programs.

Technologies de l'information — Langages de programmation — Ada

General Information

Status
Published
Publication Date
09-Dec-2012
Current Stage
9092 - International Standard to be revised
Start Date
25-Aug-2021
Completion Date
25-Aug-2021
Ref Project

RELATIONS

Buy Standard

Standard
ISO/IEC 8652:2012 - Information technology -- Programming languages -- Ada
English language
832 pages
sale 15% off
Preview
sale 15% off
Preview
Standard
ISO/IEC 8652:2012 - Information technology -- Programming languages -- Ada
English language
832 pages
sale 15% off
Preview
sale 15% off
Preview

Standards Content (sample)

INTERNATIONAL ISO/IEC
STANDARD 8652
Third edition
2012-12-15
Information technology — Programming
languages — Ada
Technologies de l'information — Langages de programmation — Ada
Reference number
ISO/IEC 8652:2012(E)
ISO/IEC 2012
---------------------- Page: 1 ----------------------
ISO/IEC 8652:2012(E)
COPYRIGHT PROTECTED DOCUMENT
© ISO/IEC 2012

All rights reserved. Unless otherwise specified, no part of this publication may be reproduced or utilized in any form or by any means,

electronic or mechanical, including photocopying and microfilm, without permission in writing from either ISO at the address below or

ISO's member body in the country of the requester.
ISO copyright office
Case postale 56  CH-1211 Geneva 20
Tel. + 41 22 749 01 11
Fax + 41 22 749 09 47
E-mail copyright@iso.org
Web www.iso.org
Published in Switzerland
ii © ISO/IEC 2012 – All rights reserved
---------------------- Page: 2 ----------------------
ISO/IEC 8652:2012(E)
Table of Contents

Table of Contents.......................................................................................................i

Foreword ..................................................................................................................xi

Introduction.............................................................................................................xii

1 General .................................................................................................................1

1.1 Scope ............................................................................................................................ 1

1.1.1 Extent...................................................................................................................... 1

1.1.2 Structure.................................................................................................................2

1.1.3 Conformity of an Implementation with the Standard ......................................... 4

1.1.4 Method of Description and Syntax Notation....................................................... 5

1.1.5 Classification of Errors ......................................................................................... 6

1.2 Normative References................................................................................................. 7

1.3 Terms and Definitions ................................................................................................. 8

2 Lexical Elements..................................................................................................9

2.1 Character Set ...............................................................................................................9

2.2 Lexical Elements, Separators, and Delimiters ........................................................ 11

2.3 Identifiers.................................................................................................................... 12

2.4 Numeric Literals......................................................................................................... 13

2.4.1 Decimal Literals................................................................................................... 13

2.4.2 Based Literals...................................................................................................... 13

2.5 Character Literals ...................................................................................................... 14

2.6 String Literals.............................................................................................................14

2.7 Comments .................................................................................................................. 15

2.8 Pragmas...................................................................................................................... 15

2.9 Reserved Words ........................................................................................................ 17

3 Declarations and Types.....................................................................................19

3.1 Declarations ............................................................................................................... 19

3.2 Types and Subtypes.................................................................................................. 20

3.2.1 Type Declarations................................................................................................ 21

3.2.2 Subtype Declarations.......................................................................................... 23

3.2.3 Classification of Operations............................................................................... 24

3.2.4 Subtype Predicates ............................................................................................. 24

3.3 Objects and Named Numbers................................................................................... 26

3.3.1 Object Declarations............................................................................................. 28

3.3.2 Number Declarations .......................................................................................... 31

3.4 Derived Types and Classes ...................................................................................... 31

3.4.1 Derivation Classes .............................................................................................. 34

3.5 Scalar Types............................................................................................................... 35

3.5.1 Enumeration Types ............................................................................................. 40

3.5.2 Character Types .................................................................................................. 41

3.5.3 Boolean Types ..................................................................................................... 42

3.5.4 Integer Types ....................................................................................................... 42

3.5.5 Operations of Discrete Types............................................................................. 44

3.5.6 Real Types............................................................................................................ 45

3.5.7 Floating Point Types ........................................................................................... 46

3.5.8 Operations of Floating Point Types................................................................... 48

3.5.9 Fixed Point Types................................................................................................ 48

3.5.10 Operations of Fixed Point Types ..................................................................... 50

i © ISO/IEC 2012 – All rights reserved
---------------------- Page: 3 ----------------------
ISO/IEC 8652:2012(E)

3.6 Array Types.................................................................................................................51

3.6.1 Index Constraints and Discrete Ranges ............................................................54

3.6.2 Operations of Array Types ..................................................................................55

3.6.3 String Types..........................................................................................................56

3.7 Discriminants..............................................................................................................56

3.7.1 Discriminant Constraints.....................................................................................59

3.7.2 Operations of Discriminated Types....................................................................60

3.8 Record Types..............................................................................................................60

3.8.1 Variant Parts and Discrete Choices....................................................................62

3.9 Tagged Types and Type Extensions.........................................................................64

3.9.1 Type Extensions...................................................................................................67

3.9.2 Dispatching Operations of Tagged Types .........................................................68

3.9.3 Abstract Types and Subprograms......................................................................71

3.9.4 Interface Types.....................................................................................................72

3.10 Access Types............................................................................................................75

3.10.1 Incomplete Type Declarations ..........................................................................77

3.10.2 Operations of Access Types .............................................................................79

3.11 Declarative Parts ......................................................................................................85

3.11.1 Completions of Declarations.............................................................................85

4 Names and Expressions ...................................................................................87

4.1 Names..........................................................................................................................87

4.1.1 Indexed Components...........................................................................................88

4.1.2 Slices.....................................................................................................................89

4.1.3 Selected Components..........................................................................................89

4.1.4 Attributes ..............................................................................................................91

4.1.5 User-Defined References.....................................................................................92

4.1.6 User-Defined Indexing .........................................................................................93

4.2 Literals.........................................................................................................................95

4.3 Aggregates..................................................................................................................96

4.3.1 Record Aggregates ..............................................................................................96

4.3.2 Extension Aggregates .........................................................................................98

4.3.3 Array Aggregates .................................................................................................99

4.4 Expressions ..............................................................................................................102

4.5 Operators and Expression Evaluation ...................................................................103

4.5.1 Logical Operators and Short-circuit Control Forms .......................................104

4.5.2 Relational Operators and Membership Tests ..................................................105

4.5.3 Binary Adding Operators...................................................................................109

4.5.4 Unary Adding Operators....................................................................................110

4.5.5 Multiplying Operators ........................................................................................110

4.5.6 Highest Precedence Operators.........................................................................112

4.5.7 Conditional Expressions ...................................................................................113

4.5.8 Quantified Expressions .....................................................................................114

4.6 Type Conversions ....................................................................................................115

4.7 Qualified Expressions..............................................................................................119

4.8 Allocators ..................................................................................................................120

4.9 Static Expressions and Static Subtypes ................................................................122

4.9.1 Statically Matching Constraints and Subtypes ...............................................125

5 Statements ....................................................................................................... 127

5.1 Simple and Compound Statements - Sequences of Statements .........................127

5.2 Assignment Statements...........................................................................................128

5.3 If Statements .............................................................................................................129

5.4 Case Statements.......................................................................................................130

© ISO/IEC 2012 – All rights reserved ii
---------------------- Page: 4 ----------------------
ISO/IEC 8652:2012(E)

5.5 Loop Statements...................................................................................................... 131

5.5.1 User-Defined Iterator Types ............................................................................. 133

5.5.2 Generalized Loop Iteration ............................................................................... 134

5.6 Block Statements..................................................................................................... 136

5.7 Exit Statements........................................................................................................ 137

5.8 Goto Statements ...................................................................................................... 137

6 Subprograms....................................................................................................139

6.1 Subprogram Declarations....................................................................................... 139

6.1.1 Preconditions and Postconditions .................................................................. 142

6.2 Formal Parameter Modes........................................................................................ 144

6.3 Subprogram Bodies ................................................................................................ 145

6.3.1 Conformance Rules........................................................................................... 146

6.3.2 Inline Expansion of Subprograms ................................................................... 148

6.4 Subprogram Calls.................................................................................................... 148

6.4.1 Parameter Associations.................................................................................... 150

6.5 Return Statements................................................................................................... 153

6.5.1 Nonreturning Procedures ................................................................................. 155

6.6 Overloading of Operators ....................................................................................... 156

6.7 Null Procedures ....................................................................................................... 157

6.8 Expression Functions ............................................................................................. 158

7 Packages ..........................................................................................................159

7.1 Package Specifications and Declarations............................................................. 159

7.2 Package Bodies ....................................................................................................... 160

7.3 Private Types and Private Extensions................................................................... 161

7.3.1 Private Operations............................................................................................. 163

7.3.2 Type Invariants .................................................................................................. 165

7.4 Deferred Constants ................................................................................................. 167

7.5 Limited Types........................................................................................................... 168

7.6 Assignment and Finalization .................................................................................. 170

7.6.1 Completion and Finalization............................................................................. 172

8 Visibility Rules .................................................................................................175

8.1 Declarative Region .................................................................................................. 175

8.2 Scope of Declarations ............................................................................................. 176

8.3 Visibility .................................................................................................................... 177

8.3.1 Overriding Indicators ........................................................................................ 179

8.4 Use Clauses ............................................................................................................. 180

8.5 Renaming Declarations........................................................................................... 181

8.5.1 Object Renaming Declarations ........................................................................ 182

8.5.2 Exception Renaming Declarations .................................................................. 183

8.5.3 Package Renaming Declarations ..................................................................... 183

8.5.4 Subprogram Renaming Declarations .............................................................. 184

8.5.5 Generic Renaming Declarations ...................................................................... 186

8.6 The Context of Overload Resolution...................................................................... 186

9 Tasks and Synchronization.............................................................................189

9.1 Task Units and Task Objects.................................................................................. 189

9.2 Task Execution - Task Activation........................................................................... 192

9.3 Task Dependence - Termination of Tasks............................................................. 193

9.4 Protected Units and Protected Objects ................................................................. 194

9.5 Intertask Communication........................................................................................ 197

9.5.1 Protected Subprograms and Protected Actions............................................. 199

9.5.2 Entries and Accept Statements........................................................................ 200

iii © ISO/IEC 2012 – All rights reserved
---------------------- Page: 5 ----------------------
ISO/IEC 8652:2012(E)

9.5.3 Entry Calls...........................................................................................................203

9.5.4 Requeue Statements..........................................................................................205

9.6 Delay Statements, Duration, and Time ...................................................................207

9.6.1 Formatting, Time Zones, and other operations for Time................................209

9.7 Select Statements.....................................................................................................215

9.7.1 Selective Accept.................................................................................................215

9.7.2 Timed Entry Calls ...............................................................................................217

9.7.3 Conditional Entry Calls......................................................................................218

9.7.4 Asynchronous Transfer of Control...................................................................219

9.8 Abort of a Task - Abort of a Sequence of Statements...........................................220

9.9 Task and Entry Attributes........................................................................................221

9.10 Shared Variables ....................................................................................................222

9.11 Example of Tasking and Synchronization............................................................223

10 Program Structure and Compilation Issues................................................ 225

10.1 Separate Compilation.............................................................................................225

10.1.1 Compilation Units - Library Units ...................................................................225

10.1.2 Context Clauses - With Clauses .....................................................................228

10.1.3 Subunits of Compilation Units........................................................................230

10.1.4 The Compilation Process ................................................................................232

10.1.5 Pragmas and Program Units ...........................................................................233

10.1.6 Environment-Level Visibility Rules ................................................................234

10.2 Program Execution.................................................................................................234

10.2.1 Elaboration Control..........................................................................................236

11 Exceptions ..................................................................................................... 241

11.1 Exception Declarations..........................................................................................241

11.2 Exception Handlers ................................................................................................242

11.3 Raise Statements....................................................................................................243

11.4 Exception Handling ................................................................................................243

11.4.1 The Package Exceptions .................................................................................244

11.4.2 Pragmas Assert and Assertion_Policy ..........................................................246

11.4.3 Example of Exception Handling......................................................................248

11.5 Suppressing Checks ..............................................................................................249

11.6 Exceptions and Optimization ................................................................................252

12 Generic Units ................................................................................................. 253

12.1 Generic Declarations..............................................................................................253

12.2 Generic Bodies .......................................................................................................255

12.3 Generic Instantiation..............................................................................................256

12.4 Formal Objects .......................................................................................................258

12.5 Formal Types ..........................................................................................................259

12.5.1 Formal Private and Derived Types .................................................................261

12.5.2 Formal Scalar Types ........................................................................................263

12.5.3 Formal Array Types..........................................................................................263

12.5.4 Formal Access Types ......................................................................................264

12.5.5 Formal Interface Types ....................................................................................265

12.6 Formal Subprograms .............................................................................................265

12.7 Formal Packages ....................................................................................................267

12.8 Example of a Generic Package .............................................................................269

13 Representation Issues .................................................................................. 273

13.1 Operational and Representation Aspects ............................................................273

13.1.1 Aspect Specifications......................................................................................276

13.2 Packed Types..........................................................................................................278

© ISO/IEC 2012 – All rights reserved iv
---------------------- Page: 6 ----------------------
ISO/IEC 8652:2012(E)

13.3 Operational and Representation Attributes ........................................................ 279

13.4 Enumeration Representation Clauses................................................................. 285

13.5 Record Layout........................................................................................................ 286

13.5.1 Record Representation Clauses .................................................................... 286

13.5.2 Storage Place Attributes................................................................................. 288

13.5.3 Bit Ordering...................................................................................................... 289

13.6 Change of Representation .................................................................................... 290

13.7 The Package System ............................................................................................. 291

13.7.1 The Package System.Storage_Elements ...................................................... 293

13.7.2 The Package System.Address_To_Access_Conversions........................... 294

13.8 Machine Code Insertions ...................................................................................... 294

13.9 Unchecked Type Conversions.............................................................................. 295

13.9.1 Data Validity..................................................................................................... 296

13.9.2 The Valid Attribute........................................................................................... 297

13.10 Unchecked Access Value Creation.................................................................... 298

13.11 Storage Management .......................................................................................... 298

13.11.1 Storage Allocation Attributes....................................................................... 301

13.11.2 Unchecked Storage Deallocation................................................................. 302

13.11.3 Default Storage Pools ................................................................................... 303

13.11.4 Storage Subpools.......................................................................................... 304

13.11.5 Subpool Reclamation.................................................................................... 306

13.11.6 Storage Subpool Example ............................................................................ 307

13.12 Pragma Restrictions and Pragma Profile .......................................................... 309

13.12.1 Language-Defined Restrictions and Profiles.............................................. 310

13.13 Streams................................................................................................................. 312

13.13.1 The Package Streams ................................................................................... 312

13.13.2 Stream-Oriented Attributes .......................................................................... 313

13.14 Freezing Rules ..................................................................................................... 318

The Standard Libraries.........................................................................................321

Annex A (normative) Predefined Language Environment ..................................323

A.1 The Package Standard............................................................................................ 326

A.2 The Package Ada .................................................................................................... 330

A.3 Character Handling ................................................................................................. 330

A.3.1 The Packages Characters, Wide_Characters, and Wide_Wide_Characters 330

A.3.2 The Package Characters.Handling.................................................................. 331

A.3.3 The Package Characters.Latin_1..................................................................... 333

A.3.4 The Package Characters.Conversions ........................................................... 338

A.3.5
...

INTERNATIONAL ISO/IEC
STANDARD 8652
Third edition
2012-12-15
Information technology — Programming
languages — Ada
Technologies de l'information — Langages de programmation — Ada
Reference number
ISO/IEC 8652:2012(E)
ISO/IEC 2012
---------------------- Page: 1 ----------------------
ISO/IEC 8652:2012(E)

This CD-ROM contains the publication ISO/IEC 8652:2012 in portable document format (PDF), which can be

viewed using Adobe® Acrobat® Reader.
Adobe and Acrobat are trademarks of Adobe Systems Incorporated.

This third edition cancels and replaces the second edition (ISO/IEC 8652:1995), which has been technically

revised. It also incorporates the Technical Corrigendum ISO/IEC 8652:1995/Cor.1:2001 and the Amendment

ISO/IEC 8652:1995/Amd.1:2007).
COPYRIGHT PROTECTED DOCUMENT
© ISO/IEC 2012

All rights reserved. Unless required for installation or otherwise specified, no part of this CD-ROM may be reproduced, stored in a retrieval

system or transmitted in any form or by any means without prior permission from ISO. Requests for permission to reproduce this product

should be addressed to
ISO copyright office  Case postale 56  CH-1211 Geneva 20  Switzerland
Internet copyright@iso.org
Reproduction may be subject to royalty payments or a licensing agreement.
Violators may be prosecuted.
Published in Switzerland
ii © ISO/IEC 2012 – All rights reserved
---------------------- Page: 2 ----------------------
ISO/IEC 8652:2012(E)
Installation

If this publication has been packaged as a zipped file, do NOT open the file from the CD-ROM, but copy it t

...

Questions, Comments and Discussion

Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.