Control Flow - Control Structures in Practice

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
  • 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 END for everything
    • Visual Basic: every control structure has its own keyword. If ... End If; For ... Next; Do ... Loop; While ... Wend

Read more about this topic:  Control Flow

Famous quotes containing the words control, structures and/or practice:

    America is neither free nor brave, but a land of tight, iron- clanking little wills, everybody trying to put it over everybody else, and a land of men absolutely devoid of the real courage of trust, trust in life’s sacred spontaneity. They can’t trust life until they can control it.
    —D.H. (David Herbert)

    The American who has been confined, in his own country, to the sight of buildings designed after foreign models, is surprised on entering York Minster or St. Peter’s at Rome, by the feeling that these structures are imitations also,—faint copies of an invisible archetype.
    Ralph Waldo Emerson (1803–1882)

    My paternal grandmother would not light a fire on the Sabbath and piled all Sunday’s washing-up in a bucket, to be dealt with on Monday morning, because the Sabbath was a day of rest—a practice that made my paternal grandfather, the village atheist, as mad as fire. Nevertheless, he willed five quid to the minister, just to be on the safe side.
    Angela Carter (1940–1992)