Structured program theorem: Difference between revisions

Content deleted Content added
Line 52:
Some academics took a purist approach to the Böhm–Jacopini result and argued that even instructions like <code>break</code> and <code>return</code> from the middle of loops are bad practice as they are not needed in the Böhm–Jacopini proof, and thus they advocated that all loops should have a single exit point. This purist approach is embodied in the [[Pascal (programming language)|Pascal programming language]] (designed in 1968–1969), which up to the mid-1990s was the preferred tool for teaching introductory programming classes in academia.{{sfn|Roberts|1995}}
 
[[Edward Yourdon]] notes that in the 1970s there was even philosophical opposition to transforming unstructured programs into structured ones by automated means, based on the argument that one needed to think in structured programming fashion from the get go. The pragmatic counterpoint was that such transformations benefited a large body of existing programs.{{sfn|Yourdon|1979|pp=49-50}} Among the first proposals for an automated transformation was a 1971 paper by Edward Ashcroft and [[Zohar Manna]].{{refn|{{harvnbsfn|Ashcroft|Manna|1971}} The paper, which is difficult to obtain in the original conference proceedings due to their limited distribution, was republished in {{harvnb|Yourdon|1979|pp= 51-65}}.}}
 
The direct application of the Böhm–Jacopini theorem may result in additional local variables being introduced in the structured chart, and may also result in some [[code duplication]].{{sfn|Watt|Findlay|2004|page=228}} The latter issue is called the [[loop and a half problem]] in this context.{{sfn|Louden|Lambert|2011|pages=422–423}} Pascal is affected by both of these problems and according to empirical studies cited by [[Eric S. Roberts]], student programmers had difficulty formulating correct solutions in Pascal for several simple problems, including writing a function for searching an element in an array. A 1980 study by Henry Shapiro cited by Roberts found that using only the Pascal-provided control structures, the correct solution was given by only 20% of the subjects, while no subject wrote incorrect code for this problem if allowed to write a return from the middle of a loop.{{sfn|Roberts|1995}}