Control Structures in Practice
Most programming languages with control structures have an initial keyword which indicates the type of control structure involved. Languages then divide as to whether or not control structures have a final keyword.
- No final keyword: Algol 60, C, C++, Haskell, Java, Pascal, Perl, PHP, PL/I, Python, PowerShell. Such languages need some way of grouping statements together:
- Algol 60 and Pascal :
begin...end - C, C++, Java, Perl, PHP, and PowerShell: curly brackets
{...} - PL/1:
DO...END - Python: uses indentation level (see Off-side rule)
- Haskell: either indentation level or curly brackets can be used, and they can be freely mixed
- Algol 60 and Pascal :
- Final keyword: Ada, Algol 68, Modula-2, Fortran 77, Mythryl, Visual Basic. The forms of the final keyword vary:
- Ada: final keyword is
end+ space + initial keyword e.g.if...end if,loop...end loop - Algol 68, Mythryl: initial keyword spelled backwards e.g.
if...fi,case...esac - Fortran 77: final keyword is
end+ initial keyword e.g.IF...ENDIF,DO...ENDDO - Modula-2: same final keyword
ENDfor everything - Visual Basic: every control structure has its own keyword.
If...End If;For...Next;Do...Loop;While...Wend
- Ada: final keyword is
Read more about this topic: Control Flow
Famous quotes containing the words control, structures and/or practice:
“If someone does something we disapprove of, we regard him as bad if we believe we can deter him from persisting in his conduct, but we regard him as mad if we believe we cannot. In either case, the crucial issue is our control of the other: the more we lose control over him, and the more he assumes control over himself, the more, in case of conflict, we are likely to consider him mad rather than just bad.”
—Thomas Szasz (b. 1920)
“It is clear that all verbal structures with meaning are verbal imitations of that elusive psychological and physiological process known as thought, a process stumbling through emotional entanglements, sudden irrational convictions, involuntary gleams of insight, rationalized prejudices, and blocks of panic and inertia, finally to reach a completely incommunicable intuition.”
—Northrop Frye (b. 1912)
“Those who make a practice of comparing human actions are never so perplexed as when they try to see them as a whole and in the same light; for they commonly contradict each other so strangely that it seems impossible that they have come from the same shop.”
—Michel de Montaigne (15331592)