8791062-Ada-Programming.pdf

(2742 KB) Pobierz
393674476 UNPDF
DA P
P ROGRAMMING
ROGRAMMING
by Wikibooks contributors
Developed on Wikibooks ,
the open-content textbooks collection
A DA
393674476.002.png 393674476.003.png
© Copyright 2004–2007, Wikibooks contributors.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free
Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the
section entitled "GNU Free Documentation License".
Image licenses are listed in the section entitled "Image Credits."
Principal authors:
The current version of this Wikibook may be found at:
Table of Contents
.......16
About Ada........................................................................................................................................
.........16
Programming in the large...............................................................................................................................................16
Programming in the small..............................................................................................................................................17
The Language Reference Manual..................................................................................................................................17
Ada Conformity Assessment Test Suite.........................................................................................................................18
Programming in Ada...................................................................................................
.............................18
Getting Started...............................................................................................................................................................18
Language Features.........................................................................................................................................................18
Computer Programming.................................................................................................................................................19
Language Summary.......................................................................................................................................................19
Predefined Language Libraries......................................................................................................................................19
Other Language Libraries..............................................................................................................................................20
External resources.........................................................................................................
...........................20
Source Code.........................................................................................................................................
.....20
References.................................................................................................................................................
20
..................21
Resources.......................................................................................................................................................................21
Manuals and guides........................................................................................................................................................21
Associations...................................................................................................................................................................21
Free online books/courses..............................................................................................................................................21
Authors and contributors.............................................................................................................
.............21
.......................23
"Hello, world!" programs..........................................................................................................
...............23
"Hello, world!"...............................................................................................................................................................23
"Hello, world!" with renames........................................................................................................................................24
"Hello, world!" with use................................................................................................................................................24
FAQ: Why is "Hello, world!" so big?............................................................................................................................24
Things to look out for...................................................................................................................
............25
Comb Format.................................................................................................................................................................25
Notes.........................................................................................................................................
................26
Type and subtype...........................................................................................................................................................26
Constrained types and unconstrained types...................................................................................................................26
Dynamic types................................................................................................................................................................27
Separation of concerns...................................................................................................................................................27
3I NSTALLING .............................................................................................................
...............28
............28
DEC Ada from HP.............................................................................................................................
.......29
GNAT, the GNU Ada Compiler from AdaCore and the Free Software Foundation...............................29
GNAT GPL Edition........................................................................................................................................................29
GNAT Modified GPL releases.......................................................................................................................................30
GNAT 3.15p.........................................................................................................................
...........30
..........................31
The GNU Ada Project....................................................................................................................................................31
GNAT for AVR microcontrollers...................................................................................................................................32
Prebuilt packages as part of larger distributions............................................................................................................32
AIDE (for Microsoft Windows)..............................................................................
.......................32
Blastwave (for Solaris on SPARC and x86)................................................................................
...32
1P REFACE .........................................................................................................................
See also...................................................................................................................................
2B ASIC ............................................................................................................
AdaMagic from SofCheck..........................................................................................
.............................28
AdaMULTI from Green Hills Software.......................................................................................
GNAT Pro..............................................................................................................
.........................30
GCC......................................................................................................................
393674476.004.png
Chapter
..................33
Debian (GNU/Linux and GNU/kFreeBSD)..........................................................................
.........33
...................34
FreeBSD.....................................................................................................................................
.....34
....................35
GNAT for Macintosh (for Mac OS 9 and X)................................................................................35
Mandriva Linux.......................................................................................................
.......................35
MinGW (for Microsoft Windows).................................................................................................
.35
SuSE Linux......................................................................................................................
...............36
....................36
Janus/Ada 83 and 95 from RR Software..............................................................................................
....36
..................37
Power Ada from OC Systems..................................................................................................................
.37
Rational Apex from IBM Rational................................................................................................
...........37
......................37
XD Ada from SWEP-EDS..............................................................................................
.........................37
.......................38
Building with various compilers............................................................................................
..................38
GNAT.............................................................................................................................................................................38
GNAT command line..........................................................................................................
......................38
GNAT with Xcode......................................................................................................
............38
....................39
Rational APEX...............................................................................................................................................................39
ObjectAda......................................................................................................................................................................40
DEC Ada for VMS.........................................................................................................................................................40
DEC Ada IDE.........................................................................................................
........................41
To be completed.............................................................................................................................................................41
Compiling our Demo Source...................................................................................................................
.41
GNAT.............................................................................................................................................................................42
Rational APEX...............................................................................................................................................................42
ObjectAda......................................................................................................................................................................43
ObjectAda commandline...............................................................................................
.................43
See also...................................................................................................................................
..................44
.................................45
Conditionals......................................................................................................................................
........45
if-else..............................................................................................................................................................................45
Optimizing hints.............................................................................................................................................................46
case.................................................................................................................................................................................46
Unconditionals...................................................................................................................................
.......47
return..............................................................................................................................................................................47
goto.................................................................................................................................................................................47
Isn't goto evil?........................................................................................................................
.........................48
Endless Loop..................................................................................................................................................................48
Loop with Condition at the Beginning...........................................................................................................................48
loop with condition at the end........................................................................................................................................49
loop with condition in the middle..................................................................................................................................49
for loop...........................................................................................................................................................................49
for loop on arrays...................................................................................................................
.........47
.........50
Working Demo.........................................................................................................................
.......50
..................51
Wikibook........................................................................................................................................................................51
Ada Reference Manual...................................................................................................................................................51
Cygwin (for Microsoft Windows)................................................................................
DJGPP (for MS-DOS).................................................................................................
Gentoo GNU/Linux....................................................................................................
ICC from Irvine Compiler Corporation...............................................................................
ObjectAda from Aonix...........................................................................................................
SCORE from DDC-I..........................................................................................................
4B UILDING .......................................................................................................
GNAT IDE................................................................................................................
5C ONTROL .............................................................................................
Loops...............................................................................................................................
See also...................................................................................................................................
393674476.005.png
......................52
Predefined types..............................................................................................................
..............53
Concurrency Types....................................................................................................................
...............55
Limited Types.........................................................................................................................
..................55
Defining new types and subtypes........................................................................................................
.....55
Creating subtypes...........................................................................................................................................................56
Derived types.................................................................................................................................................................56
Subtype categories............................................................................................................................
........57
Anonymous subtype.......................................................................................................................................................57
Base type........................................................................................................................................................................57
Constrained subtype.......................................................................................................................................................57
Definite subtype.............................................................................................................................................................57
Indefinite subtype...........................................................................................................................................................57
Named subtype...............................................................................................................................................................58
Unconstrained subtype...................................................................................................................................................58
Qualified expressions.........................................................................................................
.................59
Explicit type conversion.................................................................................................................................................60
Change of Representation..............................................................................................................................................61
Checked conversion for non-numeric types...................................................................................................................61
View conversion, in object-oriented programming........................................................................................................62
View renaming.....................................................................................................................
...........63
Address conversion........................................................................................................................................................63
Unchecked conversion...................................................................................................................................................63
Overlays.........................................................................................................................................................................64
Export / Import...............................................................................................................................................................65
See also...................................................................................................................................
..................65
Wikibook........................................................................................................................................................................65
Ada Reference Manual...................................................................................................................................................65
7I NTEGER TYPES .....................................................................................................
..................67
..................67
Wikibook........................................................................................................................................................................67
Ada Reference Manual...................................................................................................................................................67
.............68
Description.............................................................................................................................................
..................68
Wikibook........................................................................................................................................................................68
Ada Reference Manual...................................................................................................................................................68
...68
.................................69
Operators and attributes...........................................................................................................................
69
Characters as enumeration literals.................................................................................................................................70
Booleans as enumeration literals....................................................................................................................................70
Enumeration subtypes.....................................................................................................
.........................70
See also...................................................................................................................................
..................71
Wikibook........................................................................................................................................................................71
Ada Reference Manual...................................................................................................................................................71
.......................72
Description.............................................................................................................................................
...72
6T YPE S YSTEM ..................................................................................................
.........................52
The Type Hierarchy....................................................................................................................
......................59
Type conversions.....................................................................................................................
Working demo................................................................................................................
..........................67
See also...................................................................................................................................
8U NSIGNED INTEGER TYPES ...........................................................................................
See also...................................................................................................................................
9E NUMERATIONS .....................................................................................
.69
Enumeration literals..................................................................................................................................
10F LOATING POINT TYPES ...................................................................................
393674476.001.png
Zgłoś jeśli naruszono regulamin