Control flow: Difference between revisions

Content deleted Content added
Davidfstr (talk | contribs)
m Stressed the special usage of the word "obeyed"
Control structures in practice: Ada example, NPOV: sort languages alphabeticly
Line 126:
== Control structures in practice ==
 
Most programming languages with control structures have an initial keyword which indicates the type of control structure involved (Smalltalk is an exception). Languages then divide as to whether or not control structures have a final keyword.
have an initial keyword which indicates the type of control structure involved
(Smalltalk is an exception).
Languages then divide as to whether or not control structures have a final keyword.
 
* No final keyword: [[Algol programming language|Algol 60]], [[C programming language|C]], [[C plus plus|C++]], [[Java programming language|Java]], [[Pascal programming language|Pascal]], [[PL/I programming language|PL/1]].<br>
[[Pascal programming language|Pascal]], [[C programming language|C]],
[[C plus plus|C++]], [[Java programming language|Java]],
[[PL/I programming language|PL/1]].<br>
Such languages need some way of grouping statements together,
e.g.** Algol 60 and Pascal : '''begin''' ... '''end''' for Algol 60 and Pascal;
curly brackets { } for** C, C++, and Java;: DOcurly ENDbrackets for'''{''' PL/1... '''}'''
** PL/1: '''DO''' ... '''END'''
* Final keyword: [[Ada programming language|Ada]], [[Algol 68]], [[Modula-2]], [[Fortran]] (77 onwards). The forms of the final keyword vary:
Fortran** 77Ada: final keyword is '''end''' + space + initial keyword, IF'''if''' ENDIF,... DO'''end ENDDOif''' '''loop''' ... '''end loop'''
** Algol 68: initial keyword backwards e.g. '''if''' ... '''fi''', '''case''' ... '''esac''',<br>
** Fortran 77: final keyword is '''end''' + initial keyword, '''IF''' ... '''ENDIF''', '''DO''' ... '''ENDDO'''
** Modula-2: same final keyword '''end''' for everything (now thought not to be good idea),<br>
 
Languages which have a final keyword tend to have less debate regarding layout and indentation. Languages whose final keyword is of the form: '''end''' + initial keyword (with or without space in the middle) tend to be easier to learn.
Final keyword: Algol 68, [[Modula-2]], [[Fortran]] (77 onwards).
The forms of the final keyword vary:<br>
Algol 68: initial keyword backwards e.g. '''if''' '''fi''', '''case''' '''esac''',<br>
Modula-2: same final keyword '''end''' for everything (now thought not to be good idea),<br>
Fortran 77: final keyword is '''end''' + initial keyword, IF ENDIF, DO ENDDO
 
Languages which have a final keyword tend to have less debate
regarding layout and indentation.
Languages whose final keyword is of the form: '''end''' + initial keyword
tend to be easier to learn.
 
== Choice ==