Posts

Showing posts from October, 2018

Ada Pre and Post Conditions

Ada preconditions and post-conditions are implemented using aspect clauses. While aspect clauses can include many other terms used to specify program behavior, this posting will focus on preconditions and post-conditions. A thorough discussion of preconditions and post-conditions can be found at http://www.ada-auth.org/standards/12rat/html/Rat12-2-3.html Since its first official version in 1983 the Ada language has always allowed the programmer to define data types and subtypes with specific ranges. For example: type Byte is range -2**7..2**7 – 1;          -- signed integer type type Unsigned_Byte is mod 2**8;              -- modular type type Normalized is digits 5 range 0.0..1.0; -- floating point type type Money is digits 10 delta 0.01;          -- decimal fixed point type subtype Uppers is Character...

Ada Concurrency

Sequential Programming Traditional programs are sequential, performing actions in a specified sequence. The classical pattern for sequential program execution is described as Input, Process, Output. This pattern may be performed once or it may be performed many times using either iteration or recursion. This pattern is very effective at doing one thing at a time for one user. The pattern exhibits serious limitations when dealing with multiple events overlapping in time, or with multiple users. For instance, the following sequential program calculates the sum of the digits in an integer. The program supports one user who enters a single number. 1   Simple Sequential Program ----------------------------------------------------------------------- -- calculate the sum of the digits of a positive integer ----------------------------------------------------------------------- with Ada.Text_IO; use Ada.Text_Io; with Ada.Integer_Text_IO; use Ada.Integer_Te...