A Block in ADA contains two parts specification and a body. The specification specifies the variable used inside the block and the body executes the statement for the block
- The main purpose of blocks are information hiding.
- A Variable declared inside a block is accessible only within the block and nowhere outside the block.
for x in 1..10 loop
for x in 1..5 loop
(NB: the above example shows two variables x within the block and outside the block, The x inside the block is accessible only within that block)
Procedures and Functions
- Blocks are repeated whenever they are needed, but functions can be written once, called anytimes
//to define a function to show the smaller among two integers
function SMALLER (A,B: integer) return integer is
if A < B then
//function calling SMALLER