<s>
Structured	B-Language
programming	I-Language
is	O
a	O
programming	O
paradigm	O
aimed	O
at	O
improving	O
the	O
clarity	O
,	O
quality	O
,	O
and	O
development	O
time	O
of	O
a	O
computer	B-Application
program	I-Application
by	O
making	O
extensive	O
use	O
of	O
the	O
structured	O
control	O
flow	O
constructs	O
of	O
selection	O
(	O
if/then/else	B-Language
)	O
and	O
repetition	O
(	O
while	O
and	O
for	B-Language
)	O
,	O
block	O
structures	O
,	O
and	O
subroutines	O
.	O
</s>
<s>
It	O
emerged	O
in	O
the	O
late	O
1950s	O
with	O
the	O
appearance	O
of	O
the	O
ALGOL	B-Language
58	I-Language
and	O
ALGOL	B-Language
60	I-Language
programming	I-Language
languages	I-Language
,	O
with	O
the	O
latter	O
including	O
support	O
for	B-Language
block	O
structures	O
.	O
</s>
<s>
Contributing	O
factors	O
to	O
its	O
popularity	O
and	O
widespread	O
acceptance	O
,	O
at	O
first	O
in	O
academia	O
and	O
later	O
among	O
practitioners	O
,	O
include	O
the	O
discovery	O
of	O
what	O
is	O
now	O
known	O
as	O
the	O
structured	O
program	O
theorem	O
in	O
1966	O
,	O
and	O
the	O
publication	O
of	O
the	O
influential	O
"	O
Go	O
To	O
Statement	O
Considered	O
Harmful	O
"	O
open	O
letter	O
in	O
1968	O
by	O
Dutch	O
computer	O
scientist	O
Edsger	O
W	O
.	O
Dijkstra	O
,	O
who	O
coined	O
the	O
term	O
"	O
structured	B-Language
programming	I-Language
"	O
.	O
</s>
<s>
Structured	B-Language
programming	I-Language
is	O
most	O
frequently	O
used	O
with	O
deviations	O
that	O
allow	O
for	B-Language
clearer	O
programs	O
in	O
some	O
particular	O
cases	O
,	O
such	O
as	O
when	O
exception	B-General_Concept
handling	I-General_Concept
has	O
to	O
be	O
performed	O
.	O
</s>
<s>
The	O
conditional	B-Language
statement	O
should	O
have	O
at	O
least	O
one	O
true	O
condition	O
and	O
each	O
condition	O
should	O
have	O
one	O
exit	O
point	O
at	O
max	O
.	O
</s>
<s>
This	O
is	O
usually	O
expressed	O
with	O
keywords	O
such	O
as	O
while	O
,	O
repeat	O
,	O
for	B-Language
or	O
do	O
..	O
until	O
.	O
</s>
<s>
Block-structured	O
languages	O
have	O
a	O
syntax	O
for	B-Language
enclosing	O
structures	O
in	O
some	O
formal	O
way	O
,	O
such	O
as	O
an	O
if-statement	O
bracketed	O
by	O
if	O
..	O
fi	O
as	O
in	O
ALGOL	B-Language
68	I-Language
,	O
or	O
a	O
code	O
section	O
bracketed	O
by	O
BEGIN	O
..	O
END	O
,	O
as	O
in	O
PL/I	B-Language
and	O
Pascal	B-Application
,	O
whitespace	O
indentation	O
as	O
in	O
Python	B-Language
,	O
or	O
the	O
curly	O
braces	O
 { ... } 	O
of	O
C	B-Language
and	O
many	O
later	O
languages	O
.	O
</s>
<s>
It	O
is	O
possible	O
to	O
do	O
structured	B-Language
programming	I-Language
in	O
any	O
programming	O
language	O
,	O
though	O
it	O
is	O
preferable	O
to	O
use	O
something	O
like	O
a	O
procedural	B-Application
programming	I-Application
language	I-Application
.	O
</s>
<s>
Some	O
of	O
the	O
languages	O
initially	O
used	O
for	B-Language
structured	B-Language
programming	I-Language
include	O
:	O
ALGOL	B-Language
,	O
Pascal	B-Application
,	O
PL/I	B-Language
,	O
Ada	B-Language
and	O
RPL	B-Device
but	O
most	O
new	O
procedural	B-Application
programming	I-Application
languages	I-Application
since	O
that	O
time	O
have	O
included	O
features	O
to	O
encourage	O
structured	B-Language
programming	I-Language
,	O
and	O
sometimes	O
deliberately	O
left	O
out	O
features	O
–	O
notably	O
GOTO	O
–	O
in	O
an	O
effort	O
to	O
make	O
unstructured	B-Application
programming	I-Application
more	O
difficult	O
.	O
</s>
<s>
Structured	B-Language
programming	I-Language
(	O
sometimes	O
known	O
as	O
modular	O
programming	O
)	O
enforces	O
a	O
logical	O
structure	O
on	O
the	O
program	O
being	O
written	O
to	O
make	O
it	O
more	O
efficient	O
and	O
easier	O
to	O
understand	O
and	O
modify	O
.	O
</s>
<s>
The	O
structured	O
program	O
theorem	O
provides	O
the	O
theoretical	O
basis	O
of	O
structured	B-Language
programming	I-Language
.	O
</s>
<s>
It	O
states	B-Application
that	O
three	O
ways	O
of	O
combining	O
programssequencing	O
,	O
selection	O
,	O
and	O
iterationare	O
sufficient	O
to	O
express	O
any	O
computable	O
function	O
.	O
</s>
<s>
This	O
observation	O
did	O
not	O
originate	O
with	O
the	O
structured	B-Language
programming	I-Language
movement	O
;	O
these	O
structures	O
are	O
sufficient	O
to	O
describe	O
the	O
instruction	B-General_Concept
cycle	I-General_Concept
of	O
a	O
central	B-General_Concept
processing	I-General_Concept
unit	I-General_Concept
,	O
as	O
well	O
as	O
the	O
operation	O
of	O
a	O
Turing	B-Architecture
machine	I-Architecture
.	O
</s>
<s>
P	O
.	O
J	O
.	O
Plauger	O
,	O
an	O
early	O
adopter	O
of	O
structured	B-Language
programming	I-Language
,	O
described	O
his	O
reaction	O
to	O
the	O
structured	O
program	O
theorem	O
:	O
</s>
<s>
In	O
his	O
1974	O
paper	O
,	O
"	O
Structured	B-Language
Programming	I-Language
with	O
Goto	O
Statements	O
"	O
,	O
he	O
gave	O
examples	O
where	O
he	O
believed	O
that	O
a	O
direct	O
jump	O
leads	O
to	O
clearer	O
and	O
more	O
efficient	O
code	O
without	O
sacrificing	O
provability	O
.	O
</s>
<s>
Knuth	O
proposed	O
a	O
looser	O
structural	O
constraint	O
:	O
It	O
should	O
be	O
possible	O
to	O
draw	O
a	O
program	O
's	O
flow	B-Language
chart	I-Language
with	O
all	O
forward	O
branches	O
on	O
the	O
left	O
,	O
all	O
backward	O
branches	O
on	O
the	O
right	O
,	O
and	O
no	O
branches	O
crossing	O
each	O
other	O
.	O
</s>
<s>
Many	O
of	O
those	O
knowledgeable	O
in	O
compilers	B-Language
and	O
graph	O
theory	O
have	O
advocated	O
allowing	O
only	O
reducible	O
flow	O
graphs	O
.	O
</s>
<s>
Structured	B-Language
programming	I-Language
theorists	O
gained	O
a	O
major	O
ally	O
in	O
the	O
1970s	O
after	O
IBM	O
researcher	O
Harlan	O
Mills	O
applied	O
his	O
interpretation	O
of	O
structured	B-Language
programming	I-Language
theory	O
to	O
the	O
development	O
of	O
an	O
indexing	O
system	O
for	B-Language
The	O
New	O
York	O
Times	O
research	O
file	O
.	O
</s>
<s>
The	O
project	O
was	O
a	O
great	O
engineering	O
success	O
,	O
and	O
managers	O
at	O
other	O
companies	O
cited	O
it	O
in	O
support	O
of	O
adopting	O
structured	B-Language
programming	I-Language
,	O
although	O
Dijkstra	O
criticized	O
the	O
ways	O
that	O
Mills	O
's	O
interpretation	O
differed	O
from	O
the	O
published	O
work	O
.	O
</s>
<s>
As	O
late	O
as	O
1987	O
it	O
was	O
still	O
possible	O
to	O
raise	O
the	O
question	O
of	O
structured	B-Language
programming	I-Language
in	O
a	O
computer	O
science	O
journal	O
.	O
</s>
<s>
By	O
the	O
end	O
of	O
the	O
20th	O
century	O
,	O
nearly	O
all	O
computer	O
scientists	O
were	O
convinced	O
that	O
it	O
is	O
useful	O
to	O
learn	O
and	O
apply	O
the	O
concepts	O
of	O
structured	B-Language
programming	I-Language
.	O
</s>
<s>
High-level	O
programming	O
languages	O
that	O
originally	O
lacked	O
programming	O
structures	O
,	O
such	O
as	O
FORTRAN	B-Application
,	O
COBOL	B-Application
,	O
and	O
BASIC	O
,	O
now	O
have	O
them	O
.	O
</s>
<s>
While	O
goto	O
has	O
now	O
largely	O
been	O
replaced	O
by	O
the	O
structured	O
constructs	O
of	O
selection	O
(	O
if/then/else	B-Language
)	O
and	O
repetition	O
(	O
while	O
and	O
for	B-Language
)	O
,	O
few	O
languages	O
are	O
purely	O
structured	O
.	O
</s>
<s>
The	O
most	O
common	O
deviation	O
,	O
found	O
in	O
many	O
languages	O
,	O
is	O
the	O
use	O
of	O
a	O
return	B-Language
statement	I-Language
for	B-Language
early	O
exit	O
from	O
a	O
subroutine	O
.	O
</s>
<s>
This	O
results	O
in	O
multiple	O
exit	O
points	O
,	O
instead	O
of	O
the	O
single	O
exit	O
point	O
required	O
by	O
structured	B-Language
programming	I-Language
.	O
</s>
<s>
There	O
are	O
other	O
constructions	O
to	O
handle	O
cases	O
that	O
are	O
awkward	O
in	O
purely	O
structured	B-Language
programming	I-Language
.	O
</s>
<s>
The	O
most	O
common	O
deviation	O
from	O
structured	B-Language
programming	I-Language
is	O
early	O
exit	O
from	O
a	O
function	O
or	O
loop	O
.	O
</s>
<s>
At	O
the	O
level	O
of	O
functions	O
,	O
this	O
is	O
a	O
return	B-Language
statement	I-Language
.	O
</s>
<s>
In	O
structured	B-Language
programming	I-Language
,	O
these	O
can	O
be	O
replicated	O
by	O
adding	O
additional	O
branches	O
or	O
tests	O
,	O
but	O
for	B-Language
returns	O
from	O
nested	O
code	O
this	O
can	O
add	O
significant	O
complexity	O
.	O
</s>
<s>
C	B-Language
is	O
an	O
early	O
and	O
prominent	O
example	O
of	O
these	O
constructs	O
.	O
</s>
<s>
Multiple	O
exits	O
can	O
arise	O
for	B-Language
a	O
variety	O
of	O
reasons	O
,	O
most	O
often	O
either	O
that	O
the	O
subroutine	O
has	O
no	O
more	O
work	O
to	O
do	O
(	O
if	O
returning	O
a	O
value	O
,	O
it	O
has	O
completed	O
the	O
calculation	O
)	O
,	O
or	O
has	O
encountered	O
"	O
exceptional	O
"	O
circumstances	O
that	O
prevent	O
it	O
from	O
continuing	O
,	O
hence	O
needing	O
exception	B-General_Concept
handling	I-General_Concept
.	O
</s>
<s>
The	O
most	O
common	O
problem	O
in	O
early	O
exit	O
is	O
that	O
cleanup	O
or	O
final	O
statements	O
are	O
not	O
executed	O
–	O
for	B-Language
example	O
,	O
allocated	O
memory	O
is	O
not	O
deallocated	O
,	O
or	O
open	O
files	O
are	O
not	O
closed	O
,	O
causing	O
memory	B-Error_Name
leaks	I-Error_Name
or	O
resource	O
leaks	O
.	O
</s>
<s>
For	B-Language
instance	O
,	O
in	O
later	O
development	O
,	O
a	O
return	B-Language
statement	I-Language
could	O
be	O
overlooked	O
by	O
a	O
developer	O
,	O
and	O
an	O
action	O
that	O
should	O
be	O
performed	O
at	O
the	O
end	O
of	O
a	O
subroutine	O
(	O
e.g.	O
,	O
a	O
trace	O
statement	O
)	O
might	O
not	O
be	O
performed	O
in	O
all	O
cases	O
.	O
</s>
<s>
Languages	O
without	O
a	O
return	B-Language
statement	I-Language
,	O
such	O
as	O
standard	O
Pascal	B-Application
and	O
Seed7	B-Language
,	O
do	O
not	O
have	O
this	O
problem	O
.	O
</s>
<s>
This	O
is	O
most	O
often	O
known	O
as	O
try	O
...	O
finally	O
,	O
and	O
considered	O
a	O
part	O
of	O
exception	B-General_Concept
handling	I-General_Concept
.	O
</s>
<s>
In	O
case	O
of	O
multiple	O
return	B-Language
statements	I-Language
introducing	O
try	O
...	O
finally	O
,	O
without	O
exceptions	O
might	O
look	O
strange	O
.	O
</s>
<s>
An	O
alternative	O
approach	O
,	O
found	O
primarily	O
in	O
C++	O
,	O
is	O
Resource	B-Application
Acquisition	I-Application
Is	I-Application
Initialization	I-Application
,	O
which	O
uses	O
normal	O
stack	O
unwinding	O
(	O
variable	O
deallocation	O
)	O
at	O
function	O
exit	O
to	O
call	O
destructors	O
on	O
local	O
variables	O
to	O
deallocate	O
resources	O
.	O
</s>
<s>
Kent	O
Beck	O
,	O
Martin	O
Fowler	O
and	O
co-authors	O
have	O
argued	O
in	O
their	O
refactoring	O
books	O
that	O
nested	O
conditionals	B-Language
may	O
be	O
harder	O
to	O
understand	O
than	O
a	O
certain	O
type	O
of	O
flatter	O
structure	O
using	O
multiple	O
exits	O
predicated	O
by	O
guard	B-Language
clauses	I-Language
.	O
</s>
<s>
Their	O
2009	O
book	O
flatly	O
states	B-Application
that	O
"	O
one	O
exit	O
point	O
is	O
really	O
not	O
a	O
useful	O
rule	O
.	O
</s>
<s>
They	O
offer	O
a	O
cookbook	O
solution	O
for	B-Language
transforming	O
a	O
function	O
consisting	O
only	O
of	O
nested	O
conditionals	B-Language
into	O
a	O
sequence	O
of	O
guarded	O
return	O
(	O
or	O
throw	O
)	O
statements	O
,	O
followed	O
by	O
a	O
single	O
unguarded	O
block	O
,	O
which	O
is	O
intended	O
to	O
contain	O
the	O
code	O
for	B-Language
the	O
common	O
case	O
,	O
while	O
the	O
guarded	O
statements	O
are	O
supposed	O
to	O
deal	O
with	O
the	O
less	O
common	O
ones	O
(	O
or	O
with	O
errors	O
)	O
.	O
</s>
<s>
Herb	O
Sutter	O
and	O
Andrei	O
Alexandrescu	O
also	O
argue	O
in	O
their	O
2004	O
C++	O
tips	O
book	O
that	O
the	O
single-exit	O
point	O
is	O
an	O
obsolete	O
requirement	O
.	O
</s>
<s>
Using	O
Tennent	O
's	O
framework	O
notion	O
of	O
sequencer	B-Language
,	O
Watt	O
uniformly	O
describes	O
the	O
control	O
flow	O
constructs	O
found	O
in	O
contemporary	O
programming	O
languages	O
and	O
attempts	O
to	O
explain	O
why	O
certain	O
types	O
of	O
sequencers	O
are	O
preferable	O
to	O
others	O
in	O
the	O
context	O
of	O
multi-exit	O
control	O
flows	O
.	O
</s>
<s>
In	O
contrast	O
,	O
Watt	O
argues	O
that	O
the	O
conceptual	O
intent	O
of	O
a	O
return	O
sequencer	B-Language
is	O
clear	O
from	O
its	O
own	O
context	O
,	O
without	O
having	O
to	O
examine	O
its	O
destination	O
.	O
</s>
<s>
Watt	O
writes	O
that	O
a	O
class	O
of	O
sequencers	O
known	O
as	O
escape	O
sequencers	O
,	O
defined	O
as	O
a	O
"	O
sequencer	B-Language
that	O
terminates	O
execution	O
of	O
a	O
textually	O
enclosing	O
command	O
or	O
procedure	O
"	O
,	O
encompasses	O
both	O
breaks	O
from	O
loops	O
(	O
including	O
multi-level	O
breaks	O
)	O
and	O
return	B-Language
statements	I-Language
.	O
</s>
<s>
Watt	O
also	O
notes	O
that	O
while	O
jump	O
sequencers	O
(	O
gotos	O
)	O
have	O
been	O
somewhat	O
restricted	O
in	O
languages	O
like	O
C	B-Language
,	O
where	O
the	O
target	O
must	O
be	O
an	O
inside	O
the	O
local	O
block	O
or	O
an	O
encompassing	O
outer	O
block	O
,	O
that	O
restriction	O
alone	O
is	O
not	O
sufficient	O
to	O
make	O
the	O
intent	O
of	O
gotos	O
in	O
C	B-Language
self-describing	O
and	O
so	O
they	O
can	O
still	O
produce	O
"	O
spaghetti	O
code	O
"	O
.	O
</s>
<s>
Based	O
on	O
the	O
coding	O
error	O
from	O
the	O
Ariane	B-Language
501	I-Language
disaster	I-Language
,	O
software	O
developer	O
Jim	O
Bonang	O
argues	O
that	O
any	O
exceptions	O
thrown	O
from	O
a	O
function	O
violate	O
the	O
single-exit	O
paradigm	O
,	O
and	O
proposes	O
that	O
all	O
inter-procedural	O
exceptions	O
should	O
be	O
forbidden	O
.	O
</s>
<s>
Bonang	O
proposes	O
that	O
all	O
single-exit	O
conforming	O
C++	O
should	O
be	O
written	O
along	O
the	O
lines	O
of	O
:	O
</s>
<s>
Peter	O
Ritchie	O
also	O
notes	O
that	O
,	O
in	O
principle	O
,	O
even	O
a	O
single	O
throw	O
right	O
before	O
the	O
return	O
in	O
a	O
function	O
constitutes	O
a	O
violation	O
of	O
the	O
single-exit	O
principle	O
,	O
but	O
argues	O
that	O
Dijkstra	O
's	O
rules	O
were	O
written	O
in	O
a	O
time	O
before	O
exception	B-General_Concept
handling	I-General_Concept
became	O
a	O
paradigm	O
in	O
programming	O
languages	O
,	O
so	O
he	O
proposes	O
to	O
allow	O
any	O
number	O
of	O
throw	O
points	O
in	O
addition	O
to	O
a	O
single	O
return	O
point	O
.	O
</s>
<s>
He	O
notes	O
that	O
solutions	O
that	O
wrap	O
exceptions	O
for	B-Language
the	O
sake	O
of	O
creating	O
a	O
single-exit	O
have	O
higher	O
nesting	O
depth	O
and	O
thus	O
are	O
more	O
difficult	O
to	O
comprehend	O
,	O
and	O
even	O
accuses	O
those	O
who	O
propose	O
to	O
apply	O
such	O
solutions	O
to	O
programming	O
languages	O
that	O
support	O
exceptions	O
of	O
engaging	O
in	O
cargo	O
cult	O
thinking	O
.	O
</s>
<s>
David	O
Watt	O
also	O
analyzes	O
exception	B-General_Concept
handling	I-General_Concept
in	O
the	O
framework	O
of	O
sequencers	O
(	O
introduced	O
in	O
this	O
article	O
in	O
the	O
previous	O
section	O
on	O
early	O
exits	O
.	O
)	O
</s>
<s>
Watt	O
notes	O
that	O
an	O
abnormal	O
situation	O
(	O
generally	O
exemplified	O
with	O
arithmetic	O
overflows	O
or	O
input/output	O
failures	O
like	O
file	O
not	O
found	O
)	O
is	O
a	O
kind	O
of	O
error	O
that	O
"	O
is	O
detected	O
in	O
some	O
low-level	O
program	O
unit	O
,	O
but	O
[	O
for	B-Language
which ]	O
a	O
handler	O
is	O
more	O
naturally	O
located	O
in	O
a	O
high-level	O
program	O
unit	O
"	O
.	O
</s>
<s>
For	B-Language
example	O
,	O
a	O
program	O
might	O
contain	O
several	O
calls	O
to	O
read	O
files	O
,	O
but	O
the	O
action	O
to	O
perform	O
when	O
a	O
file	O
is	O
not	O
found	O
depends	O
on	O
the	O
meaning	O
(	O
purpose	O
)	O
of	O
the	O
file	O
in	O
question	O
to	O
the	O
program	O
and	O
thus	O
a	O
handling	O
routine	O
for	B-Language
this	O
abnormal	O
situation	O
cannot	O
be	O
located	O
in	O
low-level	O
system	O
code	O
.	O
</s>
<s>
Watts	O
further	O
notes	O
that	O
introducing	O
status	O
flags	O
testing	O
in	O
the	O
caller	O
,	O
as	O
single-exit	O
structured	B-Language
programming	I-Language
or	O
even	O
(	O
multi-exit	O
)	O
return	O
sequencers	O
would	O
entail	O
,	O
results	O
in	O
a	O
situation	O
where	O
"	O
the	O
application	O
code	O
tends	O
to	O
get	O
cluttered	O
by	O
tests	O
of	O
status	O
flags	O
"	O
and	O
that	O
"	O
the	O
programmer	O
might	O
forgetfully	O
or	O
lazily	O
omit	O
to	O
test	O
a	O
status	O
flag	O
.	O
</s>
<s>
He	O
notes	O
that	O
in	O
contrast	O
to	O
status	O
flags	O
testing	O
,	O
exceptions	O
have	O
the	O
opposite	O
default	B-General_Concept
behavior	I-General_Concept
,	O
causing	O
the	O
program	O
to	O
terminate	O
unless	O
the	O
programmer	O
explicitly	O
deals	O
with	O
the	O
exception	O
in	O
some	O
way	O
,	O
possibly	O
by	O
adding	O
code	O
to	O
willfully	O
ignore	O
it	O
.	O
</s>
<s>
Based	O
on	O
these	O
arguments	O
,	O
Watt	O
concludes	O
that	O
jump	O
sequencers	O
or	O
escape	O
sequencers	O
(	O
discussed	O
in	O
the	O
previous	O
section	O
)	O
are	O
n't	O
as	O
suitable	O
as	O
a	O
dedicated	O
exception	O
sequencer	B-Language
with	O
the	O
semantics	O
discussed	O
above	O
.	O
</s>
<s>
The	O
textbook	O
by	O
Louden	O
and	O
Lambert	O
emphasizes	O
that	O
exception	B-General_Concept
handling	I-General_Concept
differs	O
from	O
structured	B-Language
programming	I-Language
constructs	O
like	O
while	O
loops	O
because	O
the	O
transfer	O
of	O
control	O
"	O
is	O
set	O
up	O
at	O
a	O
different	O
point	O
in	O
the	O
program	O
than	O
that	O
where	O
the	O
actual	O
transfer	O
takes	O
place	O
.	O
</s>
<s>
Computer	O
science	O
professor	O
Arvind	O
Kumar	O
Bansal	O
also	O
notes	O
that	O
in	O
languages	O
which	O
implement	O
exception	B-General_Concept
handling	I-General_Concept
,	O
even	O
control	O
structures	O
like	O
for	B-Language
,	O
which	O
have	O
the	O
single-exit	O
property	O
in	O
absence	O
of	O
exceptions	O
,	O
no	O
longer	O
have	O
it	O
in	O
presence	O
of	O
exceptions	O
,	O
because	O
an	O
exception	O
can	O
prematurely	O
cause	O
an	O
early	O
exit	O
in	O
any	O
part	O
of	O
the	O
control	O
structure	O
;	O
for	B-Language
instance	O
if	O
init( )	O
throws	O
an	O
exception	O
in	O
for	B-Language
(init( )	O
;	O
check( )	O
;	O
increm( )	O
)	O
,	O
then	O
the	O
usual	O
exit	O
point	O
after	O
check( )	O
is	O
not	O
reached	O
.	O
</s>
<s>
Citing	O
multiple	O
prior	O
studies	O
by	O
others	O
(	O
1999-2004	O
)	O
and	O
their	O
own	O
results	O
,	O
Westley	O
Weimer	O
and	O
George	O
Necula	O
wrote	O
that	O
a	O
significant	O
problem	O
with	O
exceptions	O
is	O
that	O
they	O
"	O
create	O
hidden	O
control-flow	O
paths	O
that	O
are	O
difficult	O
for	B-Language
programmers	O
to	O
reason	O
about	O
"	O
.	O
</s>
<s>
The	O
necessity	O
to	O
limit	O
code	O
to	O
single-exit	O
points	O
appears	O
in	O
some	O
contemporary	O
programming	O
environments	O
focused	O
on	O
parallel	O
computing	O
,	O
such	O
as	O
OpenMP	B-Application
.	O
</s>
<s>
The	O
various	O
parallel	O
constructs	O
from	O
OpenMP	B-Application
,	O
like	O
parallel	O
do	O
,	O
do	O
not	O
allow	O
early	O
exits	O
from	O
inside	O
to	O
the	O
outside	O
of	O
the	O
parallel	O
construct	O
;	O
this	O
restriction	O
includes	O
all	O
manner	O
of	O
exits	O
,	O
from	O
break	O
to	O
C++	O
exceptions	O
,	O
but	O
all	O
of	O
these	O
are	O
permitted	O
inside	O
the	O
parallel	O
construct	O
if	O
the	O
jump	O
target	O
is	O
also	O
inside	O
it	O
.	O
</s>
<s>
This	O
is	O
most	O
commonly	O
only	O
re-entry	O
into	O
a	O
coroutine	B-Architecture
(	O
or	O
generator/semicoroutine	O
)	O
,	O
where	O
a	O
subprogram	O
yields	O
control	O
(	O
and	O
possibly	O
a	O
value	O
)	O
,	O
but	O
can	O
then	O
be	O
resumed	O
where	O
it	O
left	O
off	O
.	O
</s>
<s>
There	O
are	O
a	O
number	O
of	O
common	O
uses	O
of	O
such	O
programming	O
,	O
notably	O
for	B-Language
streams	B-Architecture
(	O
particularly	O
input/output	O
)	O
,	O
state	O
machines	O
,	O
and	O
concurrency	O
.	O
</s>
<s>
From	O
a	O
code	O
execution	O
point	O
of	O
view	O
,	O
yielding	O
from	O
a	O
coroutine	B-Architecture
is	O
closer	O
to	O
structured	B-Language
programming	I-Language
than	O
returning	O
from	O
a	O
subroutine	O
,	O
as	O
the	O
subprogram	O
has	O
not	O
actually	O
terminated	O
,	O
and	O
will	O
continue	O
when	O
called	O
again	O
–	O
it	O
is	O
not	O
an	O
early	O
exit	O
.	O
</s>
<s>
However	O
,	O
coroutines	B-Architecture
mean	O
that	O
multiple	O
subprograms	O
have	O
execution	O
state	O
–	O
rather	O
than	O
a	O
single	O
call	O
stack	O
of	O
subroutines	O
–	O
and	O
thus	O
introduce	O
a	O
different	O
form	O
of	O
complexity	O
.	O
</s>
<s>
It	O
is	O
very	O
rare	O
for	B-Language
subprograms	O
to	O
allow	O
entry	O
to	O
an	O
arbitrary	O
position	O
in	O
the	O
subprogram	O
,	O
as	O
in	O
this	O
case	O
the	O
program	O
state	O
(	O
such	O
as	O
variable	O
values	O
)	O
is	O
uninitialized	O
or	O
ambiguous	O
,	O
and	O
this	O
is	O
very	O
similar	O
to	O
a	O
goto	O
.	O
</s>
<s>
Some	O
programs	O
,	O
particularly	O
parsers	B-Language
and	O
communications	O
protocols	O
,	O
have	O
a	O
number	O
of	O
states	B-Application
that	O
follow	O
each	O
other	O
in	O
a	O
way	O
that	O
is	O
not	O
easily	O
reduced	O
to	O
the	O
basic	O
structures	O
,	O
and	O
some	O
programmers	O
implement	O
the	O
state-changes	O
with	O
a	O
jump	O
to	O
the	O
new	O
state	O
.	O
</s>
<s>
However	O
,	O
it	O
is	O
possible	O
to	O
structure	O
these	O
systems	O
by	O
making	O
each	O
state-change	O
a	O
separate	O
subprogram	O
and	O
using	O
a	O
variable	O
to	O
indicate	O
the	O
active	O
state	O
(	O
see	O
trampoline	B-General_Concept
)	O
.	O
</s>
<s>
Alternatively	O
,	O
these	O
can	O
be	O
implemented	O
via	O
coroutines	B-Architecture
,	O
which	O
dispense	O
with	O
the	O
trampoline	B-General_Concept
.	O
</s>
