ISO/IEC 8652:1995
(Main)Information technology — Programming languages — Ada
Information technology — Programming languages — Ada
Technologies de l'information — Langages de programmation — Ada
General Information
Relations
Standards Content (Sample)
INTERNATIONAL
ISO/IEC
STANDARD
8652
Second edition
1995-02-15
Information technology - Programming
languages - Ada
- Langages de programmation - Ada
Technologies de I’information
---------------------- Page: 1 ----------------------
ISOIIEC 8652:1995(E)
Contents
................................................................................................................. X
Forewotd
............................................................................................................. xi
Introduction
. . . . . .~~.~~~.~.~.~.~.~.~.~.~.~.~~ 1
1 l General
l.lScope .
l.l.lExtant .
...........................................................
1.1.2Structure
.......................
1.1.3 Conformity of an Implementation with the Standard
..............................
1.1.4 Method of Description and Syntax Notation
...............................................
1.1.5 Classification of Errors
......................................................
1.2 Normative References
1.3Definitions .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2. Lexical Elements
9
2.1 Character Set. .
................................... 10
2.2 Lexical Elements, Separators, and Delimiters
11
2.3Identifiers .
..........................................................
12
2.4 Numeric Literals
..................................................... 12
2.4.1 Decimal Literals
....................................................... 12
2.4.2 Based Literals
......................................................... 13
2.5 Character Literals
............................................................ 13
2.6 String Literals
14
2.7Commentr .
14
2.8Pragmar .
17
2.9ReservedWords .
19
. . . . .*.*.
3. Declarations and Types
19
3.1 Declaratlonr .
20
.......................................................
3.2TypesandSubtypes
.................................................... 21
3.2.1 Type Declarations
................................................. 23
3.2.2 Subtype Declaratlons
........................................... 24
3.2.3 Classificatlon of Operations
............................................... 24
3.3 Objects and Named Numbers
.................................................. 26
3.3.1 Object Declaratlons
.................................................
3.3.2 Number Declarations 28
20
3.4DerivedTypesandClasser .
....................................................
31
3.4.1 Dwlvation Classes
o ISO/lEC 1995
All nghts reserved. Unless otherwrse specified, no part of thrs pubkation may be reproduced
or utilized in any form or by any means, electronrc or mechanical, including photocopyrng and
microfilm, without permrssion In writing from the publisher.
ISO/IEC Copyright Office l Case Postale 56 l CH-l 211 Geneve 20 l Switzerland
Printed in Swrtzerland
---------------------- Page: 2 ----------------------
lSO/IEC 8652:1995(E)
35Scalarlypas .
32
3.5.1 Enumeration Types .
36
3.5.2 Character Types .
37
3.5.3BooleanTypes .
38
3.5.4IntegerTypes .
38
3.5.5 Operatlons of Discrete Types . 41
3.5.6RsalTypes .
42
.................................................
3.5.7FloatingPointTypes 43
3.5.8 Operations of Floating Point Types .
44
3.5.9FixedPointTypes .
45
3.5.10 Operations of Fixed Point Types . 47
36ArrayTypes .
48
3.6.1 Index Constraints and Discrete Ranges . 50
3.6.2 Operations of Array Types .
51
3.6.3StringTypes . 52
3.7Discriminants. .
52
3.7.1 Discriminant Constraints
.............................................. 55
3.7.2 Operations of Discriminated Types . 56
3.8RecordTypes .
56
3.8.1 Varlant Parts and Discrete Choices . 59
3.9 Tagged Types and Type Extensions . 60
3.9.1TypeExtensions. . 62
3.9.2 Dispatching Operations of Tagged Types . 63
3.9.3 Abstmct Typer and Subprograms . 65
3.lOAccessTy~s . 67
3.%OJ Incomplete Type Declaratlons . 69
70
3.10.2 Opemtions of Access Types .
3,llDeciaratlveParts. . 73
3.11.1 Completlons of Declarations 74
..........................................
4. Names and Expressions . 75
................................................................... 75
4.1Names
4.1.1IndexedComponents. . 76
............................................................ 77
4.1.2Slices.
4.1.3SeiectedComponents . 78
4.1.4Attributes . 79
4.2Literals . 80
............................................................... 81
4.3AggreIlates
4.3.1 Record Aggregates . 82
4.3.2 Extension Aggregates . 83
84
4.3.3 Array Aggregates .
4.4Expressions . 87
4.5 Operntors and Expression Evaluation 08
........................................
4.5.1 Logical Operators and Short-circuit Control Forms . 89
4.5.2 Reiational Operators and Membership Tests . 90
93
4.5.3 Binary Adding Operators .
4.5.4 Unary Adding Operators . 94
................................................. 94
4.5.5MuitipiyingOpemtors
4.5.6 Highest Precedence Operators . ; . 96
4.6 Type Conversions 97
.........................................................
4.7 Qualified Expressions . 101
4.8Allocators. . 102
103
4.9 Static Expressions and Static Subtypes .
4.9,1 Staticallw Matchina Constraints and Subtwes . 105
---------------------- Page: 3 ----------------------
lSO/lEC 8652: 1995(E)
174
.....................................................
9.7.1Sel~tiveAccept
176
..................................................
9.7.2TimedEntryCalls.
176
9.7.3ConditionaiEntryCaiis .
177
9.7.4AsynchronousTransferofControl .
178
98AbotiofaTask-AbortofaSequenceofStatements. .
179
...................................................
9,gTaskandEntryAttributes
180
9.10 Shared Variables .
161
9.11 Exampie of Tasking and Synchronkation .
.................................................. 183
10. Program Structure and Compilation Issues
183
.....................................................
lO.lSeparateCompilation
183
......................................
10.1.1 Compilation Units - Library Units
1~
10.1.2 Context Clauses - With Clauses .
186
10.1.3 Subunits of Compilation Units .
188
10.1.4 The Compilation Process .
189
10.1.5 Pragmas and Program Units .
190
10.1.6 Environment-Level Visibility IRules .
191
10.2 Program Execution .
193
10.2.1 ElaborationControl .
11. Exceptions . 195
195
..................................................
ll.lExceptionDeclarations.
195
.....................................................
11.2ExceptionHandlers.
196
11.3 Raise Statements .
..................................................... 197
11.4ExceptionHandllng.
197
11.4.1 The Package Exceptions .
....................................... 199
11.4.2 Example of Exception Handling
200
11SSuppressingChecks. .
202
11.6 Exceptions and Optimization .
205
12. Generic Units .
205
12.1GenericDeclaratlons. .
206
..........................................................
12.2GenericBodies
207
12.3GenericInstantiation. .
210
..........................................................
12.4FormalObjects
211
12.5FormalTypes. .
..................................... 212
12.51 Formal Private and Derived Types
213
12.5.2 Formal ScalarTypes .
214
12.5.3FormalArrayTypes .
.............................................. 215
12.5.4FormalAccessTypes.
215
12.6 Formal Subprograms .
217
12.7FormalPackalles .
............................................. 217
12.8ExampleofaGenericPackage
219
.....................................................................................
13. Representation Issues
219
13.1 Representationltems .
221
13.2PragmaPack .
................................................. 222
13.3 Representation Attributes
............... . ........................ 227
13.4 Enumeration Representation Clauses
........................................................... 228
13.5RecordLayout
........................................ 228
13.5.1RecordRepresentationClauses
.............................................
13.5.2StoragePlaceAttributes 230
...................................................... 230
13.5.3BltOrdering.
.................................................
13.6ChangeofRepresentation 231
.................................................... 232
13.7ThePackageSystem.
.............................. 234
13.7.1ThePackageSystem.Storage~Elements.
---------------------- Page: 4 ----------------------
lSO/lEC 8652:1995(E)
13.7.2 The Package System.Address-To-Access Conversions .
234
13.8MachineCodeinsertions. . ., . 235
.............................................. 236
13.9UncheckedTypeConversions
13.9.1DataValidity. . 237
................................................ 238
13.9.2TheValidAttribute.
13.10 Unchecked Access Vaiue Creation 238
.........................................
239
l3.11StorageManagement .
13.11 .l The Max Size-In-Stotage-Elements Attribute . 242
1~.11.2UncheckedStorageDeallocation . 242
13.1 fl .3 Pragma Conttoll . 243
243
13.12 Pragma Restrittions .
13.13Streams .
244
eams 244
13.13.1 The Package .
s . 245
13.13.2 Stream-Orient
.......................................................... 247
13.14F~~PingRuies
................................................................. 251
redefined Language Enwiron
252
.l The Package Standard .
......................................................... 255
A.2ThePackageAda
255
ng .
256
.........................................
256
:::::::.:::::::::::::::::::::::::::::: 258
§tring Handling . 262
263
A.4.l The Package Strings .
A,4.2 The Package Strings.Maps . 263
.......................................... 266
.4.3 Fixed-Length String Handling
273
ounded-Length String Handling .
nbounded-Length String Handling . 278
283
A.4.6 String-Handling Sets and Mappings .
283
A.4.7 Wide-String Handling .
285
A.5 The Numerics Packages .
266
A.5.1 Elementary Functionr .
289
A.5.2 Random Number 6eneration .
A.5.3 Attributes of Floating Point 8~~~~.~~~~~.~.~~.~.~.~~~~~.~.~.~.* . . 293
A”5.4 Attributes of Fixed Point Ty 297
.... ..:::::::::::::::::::::::::::::::::::::::: 297
A.6lnput-Output . . . .
.............................................. 298
A.7 Extemal Files and File Objects
.............................................. 299
A.8 Sequentiai and Direct Fiies
299
A.8;1 The Generic Package uentialJ0 .
300
A.8.2 File Management .
302
A.8.3 Sequential Input-Output Operations .
303
A.8.4 The Generic Package Direct-IO .
304
A,8.5 Direct Input-Output Operations .
305
A.9 The Generic Package StorageJO .
305
A.lOTextinput-Output .
307
A.10.1 ThePackageText-IO .
19.10.2 Text File Management 311
...............................................
312
A.10.3 Defauit Input, Output, and Enor Files .
313
A.10.4 Specification of Line and Page Lengths .
vi
---------------------- Page: 5 ----------------------
SO/lEC 8652:1995(E)
................. . . . . . . . . . . . . . 314
A.10.5 Operations on Columns, Limes, and Page8
................................ .‘....‘...... 317
A.10.6GetandPutProcedures
................................ 318
A.lO.7 Input-Output of Characters and Strings
........................................ 320
A.10.8 Input-Output for Integer Types
.......................................... 322
A.10.9 Input-Output for Real Types
.................................. 325
A.10.10 Input-Output for Enumeration Types
326
...................................................
A.11 WideText Input-Output
...................................................... 326
A.12 Stream Input-Output
...................................... 326
A.12.1 The Package Streams.Stream-IO
328
A.12.2 The Package Text lO.Text Streams
329
.................................................................
A.12.3 The Package WideTextJÖ.Text-Streams
329
A.13ExceptionsinInput-Output .
............................................................. 330
A.14FileSharing
331
A.l5ThePackageCommand-Line .
333
...........................................................................
6. Interface to Other Languages
333
.......................................................
B.l interfacing Pragmas
336
8.2ThePackageInterfaces .
337
.........................................................
B.3 Interfacing with C
341
......................................
8.3.1 The Package Interfaces.C.Strings
.............................. 344
B.3.2 The Generic Package Interfaces.C.Pointers
347
....................................................
8.4 Interfacing with COBOL
353
....................................................
B.5 interdacing with Fortran
357
......................................................................................
C. Systems Programming
357
..............................................
C.l Access to Machine Operations
358
...........................................
C.2 Required Representation Support
358
.........................................................
C.3 Interrupt Support
......................................... 360
C.3.1 Protected Procedure Handiers
362
...............................................
C.3.2 The Package Interrupts
............................................... 364
C.4 Preelaboration Requirements
365
....................................................
C.5 Pragma Dlscard-Names
365
....................................................
6.6 Shared Variable Controi
367
............................................
C.7 Task identific&ion and Attributes
367
.......................................
C.7.1 The Package Task-ldentification
.......................................... 368
6.7.2 The Package Task-Attributes
371
............................................................................................
D. Real-Time Systems
371
D.lTaskPrioritias .
373
........................................................
0.2 Priority Scheduiing
373
..........................................
0.2.1 The Task Dispatching Model
375
..................................
0.2.2 The Standard Task Dispatching Policy
376
....................................................
0.3 Priority Ceiling LocMng
378
....................................................
D.4 Entry Queuing Policies.
379
........................................................
D.5 DynamicPriorities
380
.........................................................
0.6 Prwmptive Abort
381
.......................................................
0.7 Tasking Restrittions
382
..........................................................
0.8 Monotonic Time
386
...........................................................
D.9DeiayAccunrcy
................................................. 387
D.lOSynchronousTaskControl
387
................................................
0.11 Asynchronous Task Control
388
..................................
0.12 Other Optimizations and Determinism Rules
391
..........................................................................................
E. Distributed Systems
391
................................................................
E.l Partitions
393
..............................................
E.2 Categorization of Library Units
vii
---------------------- Page: 6 ----------------------
lSO/lEC 8652:1995(E)
E.2.1 Shared Passive Library Units
.......................................... 394
E.2.2 Remote Types Library Units
...........................................
394
E.2.3 Remote Cali Interface Library Units
.....................................
395
E.3 Consistency of a Distributed System
.........................................
396
E.4 Remote Subprogram Calls
..................................................
397
E.4.1 Pragma Asynchronous 396
...............................................
E.4.2 Example of Use of a Remote Access-to=Class-Wide Type
................... 399
E.5 Partition Communication Subsystem
......................................... 461
F. Information Systems .“““““““.““““““““‘.“‘“““““““““““““““.““.“““““““““
403
F.l Machine Radix Attribute Definition Clause
.................................... 403
F.2ThePackageDecimal
...................................................... 404
F.3 Edited Output for Decimal Types
............................................. 405
F.3.1 Picture String Formatlon
.............................................. 466
F.3.2 Edlted Output Generation
............................................. 409
F.3.3 The Package Text-lO.Editing
414
..........................................
F.3.4 The Package Wlde-Text-lO.Editing
..................................... 417
............................................................................................................
G. Numerics
419
G.l Complex Arithmetic
....................................................... 419
G.l.l CompiexTypes
..................................................... 419
G.1.2 Complex Elementary Functions
........................................ 424
G.1.3ComplexInput-Gutput
................................................ 427
G.1.4The Package Wide_Text~lO.Complex~lO
429
................................
G.2NumericPerformanceRequirements .
430
G.2.1 Model of Floating Point Arithmetic
..................................... 430
G.2.2 Model-Oriented Attributes of Floating Point Types
........................
431
G.2.3 Model of Fixed Point Arithmetic
........................................
432
G.2.4 Accuracy Requirements for the Elementary Functionr
..................... 434
G.2.5 Performance Requlrements for Random Number Generation
............... 436
G.2.6 Accuracy Requirements for Complex Arithmetic
.......................... 436
H. Safety and Security .
439
H.1 Pragma Normalks-Scalars
................................................. 439
H.2 Documentation of Implementation Decisions
..................................
440
H.3 Reviewable Object Code
................................................... 440
H.3.1 Pragma Reviewable
.................................................. 440
H.3.2 Pragma inspection Point
441
H.4 Safety and Security Restr&tions
.......................................................................................... 442
J. Obsolescent Features .
445
J.l Renamings of Ada 83 Library Units
........................................... 445
3.2 Allowed Replacements of Characters
......................................... 445
J.3 Reduced Accuracy Subtypes
................................................ 446
3.4 The Constrained Attribute
.................................................. 446
J.SASCll .
447
J.6 Numeric Error
............................................................ 447
J.7AtCiausÖs
...............................................................
447
J.7.1 Interrupt Entries
.............................................. ; ......
448
J.8ModClauses .
449
J.gTheStorage-Slze Attribute
.................................................. 449
K. Language-Defined Attributes .
451
L. Language-Defined Pragmas .
465
---------------------- Page: 7 ----------------------
ISOIIEC 8652: 1995(E)
‘*‘~‘@“*“.*~“~‘~~“‘*.*.,,.,‘~~~,~~~,“,“““‘
467
M. Implementation-Defined Characteristics
. . . . . . .~.‘.*~.*9~*~“~‘*‘*“***~“““**“*~*~“““‘*‘**‘~*“““.“.“.,‘,‘,““‘~“,~““~ 473
N. Glossary
. . . . . . . . . . . . . . . . . . .“‘.“.‘.“.‘.‘.“‘.‘.‘.“.“‘.“‘.““.*‘.‘.*.“~~““‘~‘~“““‘~ 477
P. Syntax Summqf
501
“,‘,*‘~“,,,~~,“~‘,““‘,.‘.~.‘.‘.““““**‘.‘~.‘~.“““““*“““*““““.“~.““.,.““.““‘.,.,‘,“,
Index
ix
---------------------- Page: 8 ----------------------
iSO/lEC 8652:1995(E)
Foreword
ISO (the International Organkation for Standardkation) and IEC (the International Electrotechnical Com-
rnission) ferm the specialized system for worldwide standardization. National bedies that are members of
C participate in the development of International Standards through technical committees es-
tablished by the respective Organkation to deal with particular Felds of technical activity. ISO and IEC
technical committees collaborate in fields of mutual interest. Other international orgarkations,
govemmental and non-govemmental, in liaison with ISO and IEC, aIso take part in the werk.
In the field of information technology, ISO and IEC have established a joint technical committee,
ISO/IEiC JTC 1. Dr& International Smdards adopted by the joint technical committee are circulated to
national bodies for voting. Publication as an International Standard requires approval by at least 75 % sf
the national botlies casting a vote.
International Standard ISO/IEC $652 was prepared by Joint Technical Committee ISO/IEC JTC 1,
Information Technology.
This second edition cancels and replaces the fnst edition (ISO 8652: 1987), of which it constitutes a
technical revision.
hnexes A to J form an integral part of this International Standard. Annexes K ts P are for information
only ‘
Foreword
X
---------------------- Page: 9 ----------------------
lSO/lEC 8652:1995(E)
Introduction
This is the Ada Reference Manual.
Other available Ada documents include:
l Rationale for the Ada Programming Language - 1995 edition, which gives an introduction
to the new features of Ada, and explains the rationale behind them. Programmers should
read this fxst.
l Changes to Ada - 1987 to 1995. This document lists in detail the changes made to the 1987
edition of the Standard.
l The Annotated Ada Reference Manual @ARM). The AARM contains all of the text in the
RM%, plus various annotations. It is intended primarily for Compiler writers, Validation test
writers, and others who wish to study the fine details. The annotations include detailed
rationale for individual rules and explanations of some of the more arcane interactions among
the rules.
Design Goals
Ada was originally designed with three overriding concems: program reliability and maintenance, pro-
gramming as a human activity, and efficiency. This revision to the language was designed to provide
greater flexibility and extensibility, additional control over storage management and synchronization, and
standardized packages oriented toward supporting important application areas, while at the sarne time
retaining the original emphasis on reliability, maintainability, and efficiency.
The need for languages that promote reliability and simplify maintenance is weII established. Hence
emphasis was placed on program readability over esse of writing. For example, the rules of the language
require that program variables be explicitly declared and that their type be specified. Since the type of a
variable is invariant, Compilers tan ensure that operations on variables are compatible with the properties
intended for objects of the type. Furthermore, error-prone notations have been avoided, and the Syntax of
the language avoids the use of encoded forms in favor of more English-like constructs. FinaIly, the
language offers support for separate compilation of program units in a way that facilitates program
development and maintenance, and which provides the Same degree of checking between units as within a
mit.
Concem for the human programmer was aIso stressed during the design. Above all, an attempt was made
to keep to a relatively smalI number of
...
Questions, Comments and Discussion
Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.