Ada
Ada is a strongly typed Multi-paradigmed programming language suitable for embedded systems, device drivers and other forms of system programming.
Type
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.
General Syntax
The typical statement is completed by a semi-colon. For the assignment of b to a use:
a := b ;
Comments
-- this is an inline comment.  Everything after the -- is a comment.
Variable Declarations
Declarations can appear at the beginning of an block.
Declare i as an integer:
declareI : Integer ;begin-- programend;
Here are two ways to declare i as an integer and give it an initial value of 0:
declareI : Integer := 0 ;begin-- programend;
Method Declaration/Implementation
procedures and functions are declared by the keyword procedure or function respectively. See Ada Programming/Subprograms for details.
procedureA_Test (A, B:inInteger; C:outInteger)isbeginC := A + B;endA_Test;
functionMinimum (A, B : Integer)returnIntegerisbeginifA <= BthenreturnB;elsereturnA;endif;endMinimum;
Class methods are primitive operations (procedures and functions) declared in the same scope as the class record. See Ada_Programming/Object_Orientation for details.
Scope
Scops is decared by the use of packages which may consist of three parts: public specification (package), private specification (private) and body (package body).
packagePackage_With_BodyistypeBasic_Recordisprivate;procedureSet_A (This :inoutBasic_Record; An_A :inInteger);functionGet_A (This : Basic_Record)returnInteger;privatetypeBasic_RecordisrecordA : Integer;endrecord;endPackage_With_Body;
packagebodyPackage_With_BodyisprocedureSet_A (This :inoutBasic_Record; An_A :inInteger)isbeginThis.A := An_A;endSet_A;functionGet_A (This : Basic_Record)returnIntegerisbeginreturnThis.A;endGet_A;endPackage_With_Body;
See Ada_Programming/Packages for details.
Conditional Statements
<Describe the conditional statements in text and present
ifA < Range_Type'LastthenT_IO.Put (",");elseT_IO.New_Line;endif;
See Ada_Programming/Control#if-else for details.
Looping Statements
<Describe looping statements in English and present code examples.>
forAinRange_TypeloopI_IO.Put (Item => A, Width => 3, Base => 10);ifA < Range_Type'LastthenT_IO.Put (",");elseT_IO.New_Line;endif;endloop;
See Ada Programming/Control#loops for details.
Output Statements
<Describe how to output Hello world! including the new-line with or without a carriage return.>
withAda.Text_IO;procedureHelloisbeginAda.Text_IO.Put_Line("Hello, world!");endHello;
See Ada_Programming/Libraries/Ada.Text_IO for details.
Error Handling/Recovery
<Describe error handling and recovery. Give examples as appropriate.>
See Ada_Programming/Exceptions for details.
Containers
The following predefined packages are now available natively within Ada (since Ada 2005):
- Ada.Containers.Doubly_Linked_Lists
- Ada.Containers.Hashed_Maps
- Ada.Containers.Hashed_Sets
- Ada.Containers.Ordered_Maps
- Ada.Containers.Ordered_Sets
- Ada.Containers.Vectors
These are definite versions - indefinite versions of each area also provided. All containers are unbounded.
Algorithms
<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.>
Garbage collection
Carbage collections can be either manual or automatic - refer to your compiler handbook. If automatic collection is provided then pragma Controlled ()
For manual deallocation the package Ada.Unchecked_Deallocation is used.
See Ada Programming/Types/access for details.
Physical Structure
<Describe how the files, libararies, and parts are typically divided and arranged.>
Tips
<Please include tips that make it easier to switch to this language from another language.>
Web References
- Ada Programming - - (Index) (this wikibook is a tutorial)