- Zahn's construct
Zahn's construct, in
computer science , was a proposed structure for structuredcontrol flow in computer programming languages first described byCharles T. Zahn in 1974. The construct is primarily described in terms of an extension to looping constructs to recognize multiple means by which a loop could terminate. For example, a search loop might terminate early, when the target is found; or it might terminate after the search has been completed unsuccessfully. Zahn's construct can be used to avoidGO TO
statements when determining which case was encountered. Zahn does this by introducing a new kind of variable called a "situation indicator" in a CASE-like construct following the loop.Donald Knuth , in his paper "Structured Programming with Go To Statements", [http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf] describes two forms of Zahn's construct as follows:loop until
or ... or : repeat; then => ; ... => ; fi and:
begin until
or ... or : ; end; then => ; ... => ; fi There must also be a statement to set a specific situation indicator and exit the body of the construct.
Try-catch block s, used in modern programming languages forexception handling , are variations of Zahn's construct. The major difference is that the scope of Zahn's proposals were limited to individual loops within a program, whereas exception-handling capabilities often allow exceptions to be "thrown" from deep within acall stack and "caught" at a point higher up in the stack.References
*Knuth, D. E. "Structured Programming with Go To Statements", "Computing Surveys", Volume 6, December 1974, page 275
*Zahn, C. T. "A control statement for natural top-down structured programming" presented at Symposium on Programming Languages, Paris, 1974.External links
*Zahn, C. T. [http://www.slac.stanford.edu/cgi-wrap/getdoc/slac-pub-1530.pdf Structured Control in Programming Languages]
SLAC Pub-1530, January 1975
* [http://www.cs.toronto.edu/~gfb/scheme/control.html Control structures] defined using Scheme; Zahn's construct is the last one in the list
* [http://home.earthlink.net/~neilbawd/spwgif.txt Zahn's construct] defined using GOTOs in Forth
Wikimedia Foundation. 2010.