Control Structures
Control Structures
In Text: Chapter 7
1
Outline
Control structures
Selection
One-way
Two-way
Multi-way
Iteration
Counter-controlled
Logically-controlled
Gotos
Guarded statements
Design Choices:
Loop var must be an ordinal type of usual scope
After normal termination, loop var is undefined
The loop var cannot be changed in the loop
The loop parameters can be changed, but they
are evaluated just once, so it does not affect loop
control
Chapter 7: Control Structures 26
Ada For Loop
Syntax:
for var in [reverse] discrete_range loop
...
end loop
Design choices:
Type of the loop var is that of the discrete range; its
scope is the loop body (it is implicitly declared)
The loop var does not exist outside the loop
The loop var cannot be changed in the loop, but the
discrete range can; it does not affect loop control
The discrete range is evaluated just once