Zahn's construct
Zahn's construct in computer science, also known as the "situation case statement", was a proposed structure for structured control flow in computer programming languages first described by Charles T.[src] Zahn in 1974.[src] The construct is primarily described in terms of an extension to looping constructs to recognize multiple means by which a loop could terminate.[src] For example, a search loop might terminate early, when the target is found; or it might terminate after the search has been completed unsuccessfully.[src] Zahn's construct can be used to avoid GO TO statements when determining which case was encountered.[src] Zahn does this by introducing a new kind of variable called a situation indicator in a CASE-like construct surrounding the loop.[src] Donald Knuth, in his paper "Structured Programming with Go To Statements", describes two forms of Zahn's construct as follows: loop until or ...[src] or : repeat; then => ; ...[src] => ; fi and: begin until or ...[src] or : ; end; then => ; ...[src] => ; fi There must also be a statement to set a specific situation indicator and exit the body of the construct.[src] The following simple example involves searching a two-dimensional table for a particular item.…[src]
Zahn's construct in computer science, also known as the "situation case statement", was a proposed structure for structured control flow in computer programming languages first described by Charles T.[src] Zahn in 1974.[src] The construct is primarily described in terms of an extension to looping constructs to recognize multiple means by which a loop could terminate.[src] For example, a search loop might terminate early, when the target is found; or it might terminate after the search has been completed unsuccessfully.[src] Zahn's construct can be used to avoid GO TO statements when determining which case was encountered.[src] Zahn does this by introducing a new kind of variable called a situation indicator in a CASE-like construct surrounding the loop.[src] Donald Knuth, in his paper "Structured Programming with Go To Statements", describes two forms of Zahn's construct as follows: loop until or ...[src] or : repeat; then => ; ...[src] => ; fi and: begin until or ...[src] or : ; end; then => ; ...[src] => ; fi There must also be a statement to set a specific situation indicator and exit the body of the construct.[src] The following simple example involves searching a two-dimensional table for a particular item.[src] exitwhen found or missing; for I := 1 to N do for J := 1 to M do if table[I,J] = target then found; missing; exits found: print ("item is in table"); missing: print ("item is not in table"); endexit; Try-catch blocks, used in modern programming languages for exception handling, are substantial extensions of Zahn's construct.[src] 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 a call stack and "caught" at a point higher up in the stack.[src] Because Zahn's construct is local to a routine, it can be implemented very efficiently, without any need to 'unwind' the call stack.[src] Zahn implemented his situation case statement in his SKOL language.[src] SKOL was implemented as a set of macros for the MORTRAN Fortran preprocessor.[src] ==References== ==External links== Zahn, C.[src] T.[src] Structured Control in Programming Languages SLAC Pub-1530, January 1975 Control structures defined using Scheme; Zahn's construct is the last one in the list Zahn's construct defined using GOTOs in Forth The SKOL Programming Language Reference Manual[src]
32 sentences · 32 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Zahn's construct." encyclopegia.org, 2026, https://encyclopegia.org/wiki/zahn-s-construct. Accessed 30 November 2026.
Chicago
"Zahn's construct." encyclopegia.org. Accessed November 30, 2026. https://encyclopegia.org/wiki/zahn-s-construct.
APA
encyclopegia.org. (2026). Zahn's construct. Retrieved November 30, 2026, from https://encyclopegia.org/wiki/zahn-s-construct
Accessed November 30, 2026 · CC BY-SA 4.0 · citation page · JSON