1.0.1.0. Ada Program Structure - JulTob/Ada GitHub Wiki

Enough propaganda. Let’s back up those claims.

Simple Example

Let us start with a simple example:

with Ada.Text_IO;    -- Input-Output Standard Library

procedure Hello is
   begin 
   Ada.Text_IO.Put_Line(“Hello, Ada!”);
   end Hello;

It displays the string “Hello, Ada!” in the console.

You will may have noticed the following:

1. No curly brackets
2. Begin-End delimiters
3. Very verbose, little “programming symbols”
4. The symbols used are following mathematic standards.
5. The name of the process (it’s not main and) it’s declared with the type of unit it is.
6. End clause has the name of the process it’s ending. Just good practice, not mandatory.
7. Ada is NOT case sensitive.
8. Semicolons `;` are sentence terminators
9. Double hyphen `--`  are line comments
10. Whitespace characters are ignored beyond the first character.

Between is and begin we write declarations.

Between begin and end we write statements.

Context Clause

The With … line is a context clause.

They specify the packages that will be used. The context, or conditions where the program is executed and the contract complied.

They provide services to the current package.

In this case, we will be using facilities in the child package Ada.Text_IO. The standard library components are in child packages of the packageAda.In this case, we will be using facilities in the child package Ada.Text_IO.

You can call a clause into scope declaring it’s use, changing the code as follows:

with Ada.Text_IO;    --Input Output Standard Library

procedure Hello is
  use Ada.Text_IO;
    begin 
    Ada.Text_IO.Put_Line(“Hello, Ada!”);
    end Hello;

This makes the library directly visible.

Main Program (?)

The main program is the procedure named Hello. The precise name used for the main program can be anything; exactly which procedure is used as the program’s entry point is specified when the program is compiled.