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:
“Physical nature lies at our feet shackled with a hundred chains. What of the control of human nature? Do not point to the triumphs of psychiatry, social services or the war against crime. Domination of human nature can only mean the domination of every man by himself.”
—Johan Huizinga (18721945)
“If there are people who feel that God wants them to change the structures of society, that is something between them and their God. We must serve him in whatever way we are called. I am called to help the individual; to love each poor person. Not to deal with institutions. I am in no position to judge.”
—Mother Teresa (b. 1910)
“Fine art, that exists for itself alone, is art in a final state of impotence. If nobody, including the artist, acknowledges art as a means of knowing the world, then art is relegated to a kind of rumpus room of the mind and the irresponsibility of the artist and the irrelevance of art to actual living becomes part and parcel of the practice of art.”
—Angela Carter (19401992)