Types of branches
Pascal knows two types of branches:
They differ in how many alternatives can be named, how many “routes” could be taken.
if … then … branch there exists exactly one alternative.
It is either executed or not.
In conjunction with the word
else one can specify exactly two “paths” with regard to program flow.
Due to its binary nature,
if … then requires a Boolean expression to be evaluated.
Case … of on the other hand is n-ary, where n is greater than one.
if the supplied expression the program flow depends on can (and has to) be of any integral type, e. g. an integer or enumeration (in FreePascal also strings are legal).
Case … of branches should be considered where appropriate since they aide compiler optimizations.
By using them FPC may re-arrange statements, the given alternatives, in order to optimize for speed or size.
- conditional compilation and related compiler directives do not create branches