Ada


General

Hello world

with Ada.Text_IO;
use Ada.Text_IO;

procedure Hello is begin
  Put_Line ("Hello world!");
end Hello;

https://gcc.gnu.org/onlinedocs/gnat_ugn/Running-a-Simple-Ada-Program.html

'Image and ~'Value

Convert a value to string and vice-versa.

declare
  X : Integer := 10;
begin
  -- "10"
  Put_Line (Integer'Image (X));

  -- 20
  X := Integer'Value ("20");
end;

Built-in types

New types

-- A new type. Like {x: Integer | x ∈ [0,23]}
type Hours24  is new Integer range 0 .. 23;

-- A subtype
subtype Hours is Hours24 range 0 .. 11;

Arrays

-- a char array of size 10
Name : array (0 .. 9) of Character;

Enums

type Day is
  (Mon,
   Tue,
   Wed,
   Thu,
   Fri,
   Sat,
   Sun);

Representation clause ?? can be used if needed:

for Day use
  (Mon => 10,
   Tue => 11,
   Wed => 12,
   Thu => 13,
   Fri => 14,
   Sat => 15,
   Sun => 16);

https://learn.adacore.com/courses/Ada_For_The_CPP_Java_Developer/chapters/05_Type_System.html

Some Info

Todo