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
END
for 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:
“Religion differs from magic in that it is not concerned with control or manipulation of the powers confronted. Rather it means submission to, trust in, and adoration of, what is apprehended as the divine nature of ultimate reality.”
—Joachim Wach (18981955)
“The philosopher believes that the value of his philosophy lies in its totality, in its structure: posterity discovers it in the stones with which he built and with which other structures are subsequently built that are frequently betterand so, in the fact that that structure can be demolished and yet still possess value as material.”
—Friedrich Nietzsche (18441900)
“The mayor and Montaigne have always been two, with a very clear separation. For all of being a lawyer or a financier, we must not ignore the knavery there is in such callings. An honest man is not accountable for the vice or stupidity of his trade, and should not therefore refuse to practice it.”
—Michel de Montaigne (15331592)