Content deleted Content added
Starting to re-structure "exceptions" section to deal with structured non-local control flow in general |
|||
Line 275:
using nested loops (see Missing Control Structures below).
== Structured non-local control flow ==
Many programming languages, particularly those which favor more dynamic styles of programming, offer constructs for '''non-local control flow'''. These cause the flow of execution to jump out of a given context and resume at some predeclared point. ''[[Exception]]s'', ''[[condition]]s'', and ''[[continuation]]s'' are three common sorts of non-local control constructs.
=== Conditions in PL/I ===
[[PL/I programming language|PL/1]] has some 22 standard conditions
Line 289 ⟶ 288:
(especially SUBSCRIPTRANGE), so many programmers tried to avoid using conditions.
=== Exceptions in C++ and derived languages ===
[[C Plus Plus|C++]], [[D programming language|D]], [[Java programming language|Java]], and [[C sharp|C#]] have a special construct for exception handling:
'''try''' {
Line 303 ⟶ 302:
}
Any number and variety of '''catch''' clauses can be used above. In D, Java and C#, a '''finally''' clause can be added to the '''try''' construct. No matter how control leaves the '''try''' the code inside the '''finally''' clause is guaranteed to execute. This is useful when writing code that must relinquish an expensive resource (such as an opened file or a database connection) when finished processing:
FileStream stm = null; // C# example
Line 331 ⟶ 326:
Other languages such as [[Python programming language|Python]], [[Ruby programming language|Ruby]], and [[Objective C programming language|Objective C]] (and many others) support similar exception handling constructs.
The [[AppleScript]] [[script language]] provides several pieces of information to a "try" block:
Line 375 ⟶ 366:
== Missing control structures ==
In his 1974 [http://pplab.snu.ac.kr/courses/PL2001/papers/p261-knuth.pdf article], [[Donald Knuth]] identified two situations which were not covered
by the control structures listed above, and gave examples of control structures which could handle these situations. Despite their utility, these constructions have not yet found their way into main-stream programming languages.
=== Loop with test in the middle ===
|