Software Engineers Handbook/Language Dictionary/Multi-paradigmed/Ada
- 1 Ada
- 1.1 Type
- 1.2 Execution Entry Point
- 1.3 General Syntax
- 1.4 Comments
- 1.5 Variable Declarations
- 1.6 Method Declaration/Implementation
- 1.7 Scope
- 1.8 Conditional Statements
- 1.9 Looping Statements
- 1.10 Output Statements
- 1.11 Error Handling/Recovery
- 1.12 Containers
- 1.13 Algorithms
- 1.14 Garbage collection
- 1.15 Physical Structure
- 1.16 Tips
- 1.17 Web References
- 1.18 Books and Articles
Ada is a full Multi-paradigmed programming language implementing the following paradigmen: concurrent, distributed, generic (template metaprogramming), imperative and object-oriented (class-based) programming.
Execution Entry Point
The procedure name of the entry point can be freely choosen.
The typical statement is completed by a semi-colon. For the assignment of b to a use:
-- this is an inline comment. Everything after the -- is a comment.
Declarations can appear at the beginning of an block.
Declare i as an integer:
Here are two ways to declare i as an integer and give it an initial value of 0:
function Minimum (A, B : Integer) return Integer is begin if A <= B then return B; else return A; end if; end Minimum;
Class methods are primitive operations (procedures and functions) declared in the same scope as the class record. See Ada_Programming/Object_Orientation for details.
package Package_With_Body is type Basic_Record is private; procedure Set_A (This : in out Basic_Record; An_A : in Integer); function Get_A (This : Basic_Record) return Integer; private type Basic_Record is record A : Integer; end record ; end Package_With_Body;
package body Package_With_Body is procedure Set_A (This : in out Basic_Record; An_A : in Integer) is begin This.A := An_A; end Set_A; function Get_A (This : Basic_Record) return Integer is begin return This.A; end Get_A; end Package_With_Body;
See Ada_Programming/Packages for details.
<Describe the conditional statements in text and present
See Ada_Programming/Control#if-else for details.
<Describe looping statements in English and present code examples.>
for A in Range_Type loop I_IO.Put (Item => A, Width => 3, Base => 10); if A < Range_Type'Last then T_IO.Put (","); else T_IO.New_Line; end if; end loop;
See Ada Programming/Control#loops for details.
<Describe how to output Hello world! including the new-line with or without a carriage return.>
See Ada_Programming/Libraries/Ada.Text_IO for details.
<Describe error handling and recovery. Give examples as appropriate.>
See Ada_Programming/Exceptions for details.
The following predefined packages are now available natively within Ada (since Ada 2005):
These are definite versions - indefinite versions of each area also provided. All containers are unbounded.
<List algorithms or references to lists of algorithms available natively for this language. List ways to incorporate algorithms if they are not native to the language. Or, if not available, describe that.>
Carbage collections can be either manual or automatic - refer to your compiler handbook. If automatic collection is provided then
pragma Controlled () can deactivate atomatic collection for the named access type.
See Ada Programming/Types/access for details.
<Describe how the files, libararies, and parts are typically divided and arranged.>
<Please include tips that make it easier to switch to this language from another language.>