<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
control	O
flow	O
(	O
or	O
flow	O
of	O
control	O
)	O
is	O
the	O
order	O
in	O
which	O
individual	O
statements	O
,	O
instructions	O
or	O
function	O
calls	O
of	O
an	O
imperative	B-Application
program	I-Application
are	O
executed	B-General_Concept
or	O
evaluated	O
.	O
</s>
<s>
The	O
emphasis	O
on	O
explicit	O
control	O
flow	O
distinguishes	O
an	O
imperative	B-Application
programming	I-Application
language	I-Application
from	O
a	O
declarative	B-Language
programming	I-Language
language	I-Language
.	O
</s>
<s>
Within	O
an	O
imperative	B-Application
programming	I-Application
language	I-Application
,	O
a	O
control	O
flow	O
statement	O
is	O
a	O
statement	O
that	O
results	O
in	O
a	O
choice	O
being	O
made	O
as	O
to	O
which	O
of	O
two	O
or	O
more	O
paths	O
to	O
follow	O
.	O
</s>
<s>
For	O
non-strict	B-Application
functional	B-Language
languages	I-Language
,	O
functions	O
and	O
language	B-Language
constructs	I-Language
exist	O
to	O
achieve	O
the	O
same	O
result	O
,	O
but	O
they	O
are	O
usually	O
not	O
termed	O
control	O
flow	O
statements	O
.	O
</s>
<s>
Interrupts	B-Application
and	O
signals	B-Operating_System
are	O
low-level	O
mechanisms	O
that	O
can	O
alter	O
the	O
flow	O
of	O
control	O
in	O
a	O
way	O
similar	O
to	O
a	O
subroutine	O
,	O
but	O
usually	O
occur	O
as	O
a	O
response	O
to	O
some	O
external	O
stimulus	O
or	O
event	O
(	O
that	O
can	O
occur	O
asynchronously	B-Application
)	O
,	O
rather	O
than	O
execution	O
of	O
an	O
in-line	O
control	O
flow	O
statement	O
.	O
</s>
<s>
At	O
the	O
level	O
of	O
machine	B-Language
language	I-Language
or	O
assembly	B-Language
language	I-Language
,	O
control	O
flow	O
instructions	O
usually	O
work	O
by	O
altering	O
the	O
program	B-General_Concept
counter	I-General_Concept
.	O
</s>
<s>
For	O
some	O
central	B-General_Concept
processing	I-General_Concept
units	I-General_Concept
(	O
CPUs	O
)	O
,	O
the	O
only	O
control	O
flow	O
instructions	O
available	O
are	O
conditional	O
or	O
unconditional	B-General_Concept
branch	I-General_Concept
instructions	I-General_Concept
,	O
also	O
termed	O
jumps	O
.	O
</s>
<s>
Line	B-Application
numbers	I-Application
are	O
an	O
alternative	O
to	O
a	O
named	O
label	O
used	O
in	O
some	O
languages	O
(	O
such	O
as	O
BASIC	O
)	O
.	O
</s>
<s>
Languages	O
which	O
use	O
these	O
often	O
impose	O
the	O
constraint	O
that	O
the	O
line	B-Application
numbers	I-Application
must	O
increase	O
in	O
value	O
in	O
each	O
following	O
line	O
,	O
but	O
may	O
not	O
require	O
that	O
they	O
be	O
consecutive	O
.	O
</s>
<s>
In	O
other	O
languages	O
such	O
as	O
C	B-Language
and	O
Ada	B-Language
,	O
a	O
label	O
is	O
an	O
identifier	O
,	O
usually	O
appearing	O
at	O
the	O
start	O
of	O
a	O
line	O
and	O
immediately	O
followed	O
by	O
a	O
colon	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
C	B-Language
:	O
</s>
<s>
The	O
language	O
ALGOL	B-Language
60	I-Language
allowed	O
both	O
whole	O
numbers	O
and	O
identifiers	O
as	O
labels	O
(	O
both	O
linked	O
by	O
colons	O
to	O
the	O
following	O
statement	O
)	O
,	O
but	O
few	O
if	O
any	O
other	O
ALGOL	B-Language
variants	O
allowed	O
whole	O
numbers	O
.	O
</s>
<s>
Early	O
Fortran	B-Application
compilers	O
only	O
allowed	O
whole	O
numbers	O
as	O
labels	O
.	O
</s>
<s>
Beginning	O
with	O
Fortran-90	O
,	O
alphanumeric	O
labels	O
have	O
also	O
been	O
allowed	O
.	O
</s>
<s>
The	O
goto	B-Application
statement	O
(	O
a	O
combination	O
of	O
the	O
English	O
words	O
go	B-Application
and	O
to	O
,	O
and	O
pronounced	O
accordingly	O
)	O
is	O
the	O
most	O
basic	O
form	O
of	O
unconditional	O
transfer	O
of	O
control	O
.	O
</s>
<s>
The	O
effect	O
of	O
a	O
goto	B-Application
statement	O
is	O
to	O
cause	O
the	O
next	O
statement	O
to	O
be	O
executed	B-General_Concept
to	O
be	O
the	O
statement	O
appearing	O
at	O
(	O
or	O
immediately	O
after	O
)	O
the	O
indicated	O
label	O
.	O
</s>
<s>
Goto	B-Application
statements	O
have	O
been	O
considered	O
harmful	O
by	O
many	O
computer	B-General_Concept
scientists	I-General_Concept
,	O
notably	O
Dijkstra	O
.	O
</s>
<s>
In	O
the	O
1950s	O
,	O
computer	O
memories	O
were	O
very	O
small	O
by	O
current	O
standards	O
so	O
subroutines	O
were	O
used	O
mainly	O
to	O
reduce	O
program	B-Application
size	O
.	O
</s>
<s>
A	O
piece	O
of	O
code	O
was	O
written	O
once	O
and	O
then	O
used	O
many	O
times	O
from	O
various	O
other	O
places	O
in	O
a	O
program	B-Application
.	O
</s>
<s>
Today	O
,	O
subroutines	O
are	O
more	O
often	O
used	O
to	O
help	O
make	O
a	O
program	B-Application
more	O
structured	O
,	O
e.g.	O
,	O
by	O
isolating	O
some	O
algorithm	O
or	O
hiding	O
some	O
data	O
access	O
method	O
.	O
</s>
<s>
If	O
many	O
programmers	O
are	O
working	O
on	O
one	O
program	B-Application
,	O
subroutines	O
are	O
one	O
kind	O
of	O
modularity	B-Architecture
that	O
can	O
help	O
divide	O
the	O
work	O
.	O
</s>
<s>
In	O
structured	B-Language
programming	I-Language
,	O
the	O
ordered	O
sequencing	O
of	O
successive	O
commands	O
is	O
considered	O
one	O
of	O
the	O
basic	O
control	O
structures	O
,	O
which	O
is	O
used	O
as	O
a	O
building	O
block	O
for	O
programs	O
alongside	O
iteration	O
,	O
recursion	O
and	O
choice	O
.	O
</s>
<s>
In	O
May	O
1966	O
,	O
Böhm	O
and	O
Jacopini	O
published	O
an	O
article	O
in	O
Communications	O
of	O
the	O
ACM	O
which	O
showed	O
that	O
any	O
program	B-Application
with	O
gotos	O
could	O
be	O
transformed	O
into	O
a	O
goto-free	O
form	O
involving	O
only	O
choice	O
(	O
IF	O
THEN	O
ELSE	O
)	O
and	O
loops	O
(	O
WHILE	O
condition	O
DO	O
xxx	O
)	O
,	O
possibly	O
with	O
duplicated	O
code	O
and/or	O
the	O
addition	O
of	O
Boolean	O
variables	O
(	O
true/false	O
flags	O
)	O
.	O
</s>
<s>
That	O
such	O
minimalism	O
is	O
possible	O
does	O
not	O
mean	O
that	O
it	O
is	O
necessarily	O
desirable	O
;	O
after	O
all	O
,	O
computers	O
theoretically	O
need	O
only	O
one	B-Application
machine	I-Application
instruction	I-Application
(	O
subtract	O
one	O
number	O
from	O
another	O
and	O
branch	B-General_Concept
if	O
the	O
result	O
is	O
negative	O
)	O
,	O
but	O
practical	O
computers	O
have	O
dozens	O
or	O
even	O
hundreds	O
of	O
machine	B-Language
instructions	I-Language
.	O
</s>
<s>
What	O
Böhm	O
and	O
Jacopini	O
's	O
article	O
showed	O
was	O
that	O
all	O
programs	O
could	O
be	O
goto-free	O
.	O
</s>
<s>
(	O
Later	O
developments	O
,	O
such	O
as	O
non-strict	B-Application
programming	I-Application
languages	I-Application
–	O
and	O
more	O
recently	O
,	O
composable	O
software	B-Operating_System
transactions	I-Operating_System
–	O
have	O
continued	O
this	O
strategy	O
,	O
making	O
components	O
of	O
programs	O
even	O
more	O
freely	O
composable	O
.	O
)	O
</s>
<s>
This	O
purist	O
approach	O
is	O
embodied	O
in	O
the	O
language	O
Pascal	B-Application
(	O
designed	O
in	O
1968	O
–	O
1969	O
)	O
,	O
which	O
up	O
to	O
the	O
mid-1990s	O
was	O
the	O
preferred	O
tool	O
for	O
teaching	O
introductory	O
programming	O
in	O
academia	O
.	O
</s>
<s>
Pascal	B-Application
is	O
affected	O
by	O
both	O
of	O
these	O
problems	O
and	O
according	O
to	O
empirical	O
studies	O
cited	O
by	O
Eric	O
S	O
.	O
Roberts	O
,	O
student	O
programmers	O
had	O
difficulty	O
formulating	O
correct	O
solutions	O
in	O
Pascal	B-Application
for	O
several	O
simple	O
problems	O
,	O
including	O
writing	O
a	O
function	O
for	O
searching	O
an	O
element	O
in	O
an	O
array	O
.	O
</s>
<s>
A	O
1980	O
study	O
by	O
Henry	O
Shapiro	O
cited	O
by	O
Roberts	O
found	O
that	O
using	O
only	O
the	O
Pascal-provided	O
control	O
structures	O
,	O
the	O
correct	O
solution	O
was	O
given	O
by	O
only	O
20%	O
of	O
the	O
subjects	O
,	O
while	O
no	O
subject	O
wrote	O
incorrect	O
code	O
for	O
this	O
problem	O
if	O
allowed	O
to	O
write	O
a	O
return	O
from	O
the	O
middle	O
of	O
a	O
loop	O
.	O
</s>
<s>
No	O
final	O
keyword	O
:	O
ALGOL	B-Language
60	I-Language
,	O
C	B-Language
,	O
C++	B-Language
,	O
Haskell	B-Language
,	O
Java	B-Language
,	O
Pascal	B-Application
,	O
Perl	B-Language
,	O
PHP	B-Application
,	O
PL/I	B-Language
,	O
Python	B-Language
,	O
PowerShell	B-Application
.	O
</s>
<s>
Final	O
keyword	O
:	O
Ada	B-Language
,	O
ALGOL	B-Language
68	I-Language
,	O
Modula-2	B-Language
,	O
Fortran	B-Application
77	O
,	O
Mythryl	O
,	O
Visual	B-Language
Basic	I-Language
.	O
</s>
<s>
Visual	B-Language
Basic	I-Language
:	O
every	O
control	O
structure	O
has	O
its	O
own	O
keyword	O
.	O
</s>
<s>
Conditional	O
expressions	O
and	O
conditional	O
constructs	O
are	O
features	O
of	O
a	B-Language
programming	I-Language
language	I-Language
which	O
perform	O
different	O
computations	O
or	O
actions	O
depending	O
on	O
whether	O
a	O
programmer-specified	O
boolean	O
condition	O
evaluates	O
to	O
true	O
or	O
false	O
.	O
</s>
<s>
IF	O
..	O
GOTO	B-Application
.	O
</s>
<s>
A	O
form	O
found	O
in	O
unstructured	O
languages	O
,	O
mimicking	O
a	O
typical	O
machine	B-Language
code	I-Language
instruction	O
,	O
would	O
jump	O
to	O
(	O
GOTO	B-Application
)	O
a	O
label	O
or	O
line	B-Application
number	I-Application
when	O
the	O
condition	O
was	O
met	O
.	O
</s>
<s>
C	B-Language
and	O
related	O
languages	O
do	O
not	O
require	O
a	O
terminal	O
keyword	O
,	O
or	O
a	O
'	O
then	O
 '	O
,	O
but	O
do	O
require	O
parentheses	O
around	O
the	O
condition	O
.	O
</s>
<s>
Some	O
languages	O
,	O
such	O
as	O
Fortran	B-Application
,	O
have	O
a	O
three-way	O
or	O
arithmetic	B-Language
if	I-Language
,	O
testing	O
whether	O
a	O
numeric	O
value	O
is	O
positive	O
,	O
negative	O
or	O
zero	O
.	O
</s>
<s>
Some	O
languages	O
have	O
a	O
functional	B-Language
form	O
of	O
an	O
if	O
statement	O
,	O
for	O
instance	O
Lisp	B-Language
's	I-Language
cond	O
.	O
</s>
<s>
Some	O
languages	O
have	O
an	O
operator	O
form	O
of	O
an	O
if	O
statement	O
,	O
such	O
as	O
C	B-Language
's	O
ternary	O
operator	O
.	O
</s>
<s>
Perl	B-Language
supplements	O
a	O
C-style	O
if	O
with	O
when	O
and	O
unless	O
.	O
</s>
<s>
Smalltalk	B-Application
uses	O
ifTrue	O
and	O
ifFalse	O
messages	O
to	O
implement	O
conditionals	O
,	O
rather	O
than	O
any	O
fundamental	O
language	B-Language
construct	I-Language
.	O
</s>
<s>
Switch	O
statements	O
can	O
allow	O
compiler	O
optimizations	O
,	O
such	O
as	O
lookup	B-Data_Structure
tables	I-Data_Structure
.	O
</s>
<s>
In	O
dynamic	B-Language
languages	I-Language
,	O
the	O
cases	O
may	O
not	O
be	O
limited	O
to	O
constant	O
expressions	O
,	O
and	O
might	O
extend	O
to	O
pattern	B-Language
matching	I-Language
,	O
as	O
in	O
the	O
shell	B-Language
script	I-Language
example	O
on	O
the	O
right	O
,	O
where	O
the	O
*	O
)	O
implements	O
the	O
default	O
case	O
as	O
a	O
glob	B-Language
matching	O
any	O
string	O
.	O
</s>
<s>
can	O
also	O
be	O
implemented	O
in	O
functional	B-Language
form	O
,	O
as	O
in	O
SQL	B-Language
's	O
decode	O
statement	O
.	O
</s>
<s>
The	O
code	O
"	O
inside	O
"	O
the	O
loop	O
(	O
the	O
body	O
of	O
the	O
loop	O
,	O
shown	O
below	O
as	O
xxx	O
)	O
is	O
obeyed	O
a	O
specified	O
number	O
of	O
times	O
,	O
or	O
once	O
for	O
each	O
of	O
a	O
collection	O
of	O
items	O
,	O
or	O
until	O
some	O
condition	O
is	O
met	O
,	O
or	O
indefinitely	B-Algorithm
.	O
</s>
<s>
In	O
functional	B-Language
programming	I-Language
languages	I-Language
,	O
such	O
as	O
Haskell	B-Language
and	O
Scheme	B-Language
,	O
both	O
recursive	O
and	O
iterative	B-Application
processes	O
are	O
expressed	O
with	O
tail	O
recursive	O
procedures	O
instead	O
of	O
looping	O
constructs	O
that	O
are	O
syntactic	O
.	O
</s>
<s>
In	O
most	O
cases	O
counting	O
can	O
go	B-Application
downwards	O
instead	O
of	O
upwards	O
and	O
step	O
sizes	O
other	O
than	O
1	O
can	O
be	O
used	O
.	O
</s>
<s>
If	O
the	O
test	O
is	O
at	O
the	O
start	O
,	O
the	O
body	O
may	O
be	O
skipped	O
completely	O
;	O
if	O
it	O
is	O
at	O
the	O
end	O
,	O
the	O
body	O
is	O
always	O
executed	B-General_Concept
at	O
least	O
once	O
.	O
</s>
<s>
A	O
control	B-General_Concept
break	I-General_Concept
is	O
a	O
value	O
change	O
detection	O
method	O
used	O
within	O
ordinary	O
loops	O
to	O
trigger	O
processing	O
for	O
groups	O
of	O
values	O
.	O
</s>
<s>
Values	O
are	O
monitored	O
within	O
the	O
loop	O
and	O
a	O
change	O
diverts	O
program	B-Application
flow	O
to	O
the	O
handling	O
of	O
the	O
group	O
event	O
associated	O
with	O
them	O
.	O
</s>
<s>
Several	O
programming	O
languages	O
(	O
e.g.	O
,	O
Ada	B-Language
,	O
D	B-Application
,	O
C++11	B-Language
,	O
Smalltalk	B-Application
,	O
PHP	B-Application
,	O
Perl	B-Language
,	O
Object	B-Language
Pascal	I-Language
,	O
Java	B-Language
,	O
C#	B-Application
,	O
MATLAB	B-Language
,	O
Visual	B-Language
Basic	I-Language
,	O
Ruby	B-Language
,	O
Python	B-Language
,	O
JavaScript	B-Language
,	O
Fortran	B-Application
95	O
and	O
later	O
)	O
have	O
special	O
constructs	O
which	O
allow	O
implicit	O
looping	O
through	O
all	O
elements	O
of	O
an	O
array	O
,	O
or	O
all	O
members	O
of	O
a	O
set	O
or	O
collection	O
.	O
</s>
<s>
Scala	B-Application
has	O
for-expressions	O
,	O
which	O
generalise	O
collection-controlled	O
loops	O
,	O
and	O
also	O
support	O
other	O
uses	O
,	O
such	O
as	O
asynchronous	B-Operating_System
programming	I-Operating_System
.	O
</s>
<s>
Haskell	B-Language
has	O
do-expressions	O
and	O
comprehensions	O
,	O
which	O
together	O
provide	O
similar	O
function	O
to	O
for-expressions	O
in	O
Scala	B-Application
.	O
</s>
<s>
General	O
iteration	O
constructs	O
such	O
as	O
C	B-Language
's	O
for	O
statement	O
and	O
Common	B-Language
Lisp	I-Language
's	O
do	O
form	O
can	O
be	O
used	O
to	O
express	O
any	O
of	O
the	O
above	O
sorts	O
of	O
loops	O
,	O
and	O
others	O
,	O
such	O
as	O
looping	O
over	O
some	O
number	O
of	O
collections	O
in	O
parallel	O
.	O
</s>
<s>
Infinite	B-Algorithm
loops	I-Algorithm
are	O
used	O
to	O
assure	O
a	O
program	B-Application
segment	O
loops	O
forever	O
or	O
until	O
an	O
exceptional	O
condition	O
arises	O
,	O
such	O
as	O
an	O
error	O
.	O
</s>
<s>
For	O
instance	O
,	O
an	O
event-driven	O
program	B-Application
(	O
such	O
as	O
a	O
server	B-Application
)	O
should	O
loop	O
forever	O
,	O
handling	O
events	O
as	O
they	O
occur	O
,	O
only	O
stopping	O
when	O
the	O
process	O
is	O
terminated	O
by	O
an	O
operator	O
.	O
</s>
<s>
Infinite	B-Algorithm
loops	I-Algorithm
can	O
be	O
implemented	O
using	O
other	O
control	O
flow	O
constructs	O
.	O
</s>
<s>
Most	O
commonly	O
,	O
in	O
unstructured	O
programming	O
this	O
is	O
jump	O
back	O
up	O
(	O
goto	B-Application
)	O
,	O
while	O
in	O
structured	B-Language
programming	I-Language
this	O
is	O
an	O
indefinite	O
loop	O
(	O
while	O
loop	O
)	O
set	O
to	O
never	O
end	O
,	O
either	O
by	O
omitting	O
the	O
condition	O
or	O
explicitly	O
setting	O
it	O
to	O
true	O
,	O
as	O
while	O
(	O
true	O
)	O
....	O
</s>
<s>
Some	O
languages	O
have	O
special	O
constructs	O
for	O
infinite	B-Algorithm
loops	I-Algorithm
,	O
typically	O
by	O
omitting	O
the	O
condition	O
from	O
an	O
indefinite	O
loop	O
.	O
</s>
<s>
Examples	O
include	O
Ada	B-Language
(	O
loop	O
...	O
end	O
loop	O
)	O
,	O
Fortran	B-Application
(	O
DO	O
...	O
END	O
DO	O
)	O
,	O
Go	B-Application
(	O
for	O
{	O
...	O
}	O
)	O
,	O
and	O
Ruby	B-Language
(	O
loop	O
do	O
...	O
end	O
)	O
.	O
</s>
<s>
Often	O
,	O
an	O
infinite	B-Algorithm
loop	I-Algorithm
is	O
unintentionally	O
created	O
by	O
a	O
programming	O
error	O
in	O
a	O
condition-controlled	O
loop	O
,	O
wherein	O
the	O
loop	O
condition	O
uses	O
variables	O
that	O
never	O
change	O
within	O
the	O
loop	O
.	O
</s>
<s>
Some	O
languages	O
provide	O
a	O
statement	O
such	O
as	O
continue	O
(	O
most	O
languages	O
)	O
,	O
skip	O
,	O
or	O
next	O
(	O
Perl	B-Language
and	O
Ruby	B-Language
)	O
,	O
which	O
will	O
do	O
this	O
.	O
</s>
<s>
Some	O
languages	O
,	O
like	O
Perl	B-Language
and	O
Ruby	B-Language
,	O
have	O
a	O
redo	O
statement	O
that	O
restarts	O
the	O
current	O
iteration	O
from	O
the	O
start	O
.	O
</s>
<s>
Ruby	B-Language
has	O
a	O
retry	O
statement	O
that	O
restarts	O
the	O
entire	O
loop	O
from	O
the	O
initial	O
iteration	O
.	O
</s>
<s>
Some	O
programming	O
languages	O
provide	O
a	O
statement	O
such	O
as	O
break	O
(	O
most	O
languages	O
)	O
,	O
Exit	O
(	O
Visual	B-Language
Basic	I-Language
)	O
,	O
or	O
last	O
(	O
Perl	B-Language
)	O
,	O
which	O
effect	O
is	O
to	O
terminate	O
the	O
current	O
loop	O
immediately	O
,	O
and	O
transfer	O
control	O
to	O
the	O
statement	O
immediately	O
after	O
that	O
loop	O
.	O
</s>
<s>
The	O
following	O
example	O
is	O
done	O
in	O
Ada	B-Language
which	O
supports	O
both	O
early	O
exit	O
from	O
loops	O
and	O
loops	O
with	O
test	O
in	O
the	O
middle	O
.	O
</s>
<s>
Python	B-Language
supports	O
conditional	O
execution	O
of	O
code	O
depending	O
on	O
whether	O
a	O
loop	O
was	O
exited	O
early	O
(	O
with	O
a	O
break	O
statement	O
)	O
or	O
not	O
by	O
using	O
an	O
else-clause	O
with	O
the	O
loop	O
.	O
</s>
<s>
Both	O
Python	B-Language
's	O
for	O
and	O
while	O
loops	O
support	O
such	O
an	O
else	O
clause	O
,	O
which	O
is	O
executed	B-General_Concept
only	O
if	O
early	O
exit	O
of	O
the	O
loop	O
has	O
not	O
occurred	O
.	O
</s>
<s>
This	O
can	O
be	O
done	O
either	O
via	O
multilevel	O
breaks	O
(	O
break	O
out	O
of	O
N	O
levels	O
)	O
,	O
as	O
in	O
bash	O
and	O
PHP	B-Application
,	O
or	O
via	O
labeled	O
breaks	O
(	O
break	O
out	O
and	O
continue	O
at	O
given	O
label	O
)	O
,	O
as	O
in	O
Java	B-Language
and	O
Perl	B-Language
.	O
</s>
<s>
Alternatives	O
to	O
multilevel	O
breaks	O
include	O
single	O
breaks	O
,	O
together	O
with	O
a	O
state	O
variable	O
which	O
is	O
tested	O
to	O
break	O
out	O
another	O
level	O
;	O
exceptions	B-General_Concept
,	O
which	O
are	O
caught	O
at	O
the	O
level	O
being	O
broken	O
out	O
to	O
;	O
placing	O
the	O
nested	O
loops	O
in	O
a	O
function	O
and	O
using	O
return	O
to	O
effect	O
termination	O
of	O
the	O
entire	O
nested	O
loop	O
;	O
or	O
using	O
a	O
label	O
and	O
a	O
goto	B-Application
statement	O
.	O
</s>
<s>
C	B-Language
does	O
not	O
include	O
a	O
multilevel	O
break	O
,	O
and	O
the	O
usual	O
alternative	O
is	O
to	O
use	O
a	O
goto	B-Application
to	O
implement	O
a	O
labeled	O
break	O
.	O
</s>
<s>
Python	B-Language
does	O
not	O
have	O
a	O
multilevel	O
break	O
or	O
continue	O
–	O
this	O
was	O
proposed	O
in	O
,	O
and	O
rejected	O
on	O
the	O
basis	O
that	O
the	O
added	O
complexity	O
was	O
not	O
worth	O
the	O
rare	O
legitimate	O
use	O
.	O
</s>
<s>
The	O
notion	O
of	O
multi-level	O
breaks	O
is	O
of	O
some	O
interest	O
in	O
theoretical	O
computer	B-General_Concept
science	I-General_Concept
,	O
because	O
it	O
gives	O
rise	O
to	O
what	O
is	O
today	O
called	O
the	O
Kosaraju	O
hierarchy	O
.	O
</s>
<s>
In	O
1973	O
S	O
.	O
Rao	O
Kosaraju	O
refined	O
the	O
structured	O
program	B-Application
theorem	O
by	O
proving	O
that	O
it	O
is	O
possible	O
to	O
avoid	O
adding	O
additional	O
variables	O
in	O
structured	B-Language
programming	I-Language
,	O
as	O
long	O
as	O
arbitrary-depth	O
,	O
multi-level	O
breaks	O
from	O
loops	O
are	O
allowed	O
.	O
</s>
<s>
Furthermore	O
,	O
Kosaraju	O
proved	O
that	O
a	O
strict	O
hierarchy	O
of	O
programs	O
exists	O
:	O
for	O
every	O
integer	O
n	O
,	O
there	O
exists	O
a	O
program	B-Application
containing	O
a	O
multi-level	O
break	O
of	O
depth	O
n	O
that	O
cannot	O
be	O
rewritten	O
as	O
a	O
program	B-Application
with	O
multi-level	O
breaks	O
of	O
depth	O
less	O
than	O
n	O
without	O
introducing	O
added	O
variables	O
.	O
</s>
<s>
There	O
are	O
other	O
proposed	O
control	O
structures	O
for	O
multiple	O
breaks	O
,	O
but	O
these	O
are	O
generally	O
implemented	O
as	O
exceptions	B-General_Concept
instead	O
.	O
</s>
<s>
In	O
his	O
2004	O
textbook	O
,	O
David	O
Watt	O
uses	O
Tennent	O
's	O
notion	O
of	O
sequencer	B-Language
to	O
explain	O
the	O
similarity	O
between	O
multi-level	O
breaks	O
and	O
return	O
statements	O
.	O
</s>
<s>
Watt	O
notes	O
that	O
a	O
class	O
of	O
sequencers	O
known	O
as	O
escape	O
sequencers	O
,	O
defined	O
as	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	O
statements	O
.	O
</s>
<s>
As	O
commonly	O
implemented	O
,	O
however	O
,	O
return	O
sequencers	O
may	O
also	O
carry	O
a	O
(	O
return	O
)	O
value	O
,	O
whereas	O
the	O
break	O
sequencer	B-Language
as	O
implemented	O
in	O
contemporary	O
languages	O
usually	O
cannot	O
.	O
</s>
<s>
Loop	B-Application
variants	I-Application
and	O
loop	B-Application
invariants	I-Application
are	O
used	O
to	O
express	O
correctness	O
of	O
loops	O
.	O
</s>
<s>
In	O
practical	O
terms	O
,	O
a	O
loop	B-Application
variant	I-Application
is	O
an	O
integer	O
expression	O
which	O
has	O
an	O
initial	O
non-negative	O
value	O
.	O
</s>
<s>
Loop	B-Application
variants	I-Application
are	O
used	O
to	O
guarantee	O
that	O
loops	O
will	O
terminate	O
.	O
</s>
<s>
A	O
loop	B-Application
invariant	I-Application
is	O
an	O
assertion	O
which	O
must	O
be	O
true	O
before	O
the	O
first	O
loop	O
iteration	O
and	O
remain	O
true	O
after	O
each	O
iteration	O
.	O
</s>
<s>
This	O
implies	O
that	O
when	O
a	O
loop	O
terminates	O
correctly	O
,	O
both	O
the	O
exit	O
condition	O
and	O
the	O
loop	B-Application
invariant	I-Application
are	O
satisfied	O
.	O
</s>
<s>
Loop	B-Application
invariants	I-Application
are	O
used	O
to	O
monitor	O
specific	O
properties	O
of	O
a	O
loop	O
during	O
successive	O
iterations	O
.	O
</s>
<s>
Some	O
programming	O
languages	O
,	O
such	O
as	O
Eiffel	B-Language
contain	O
native	O
support	O
for	O
loop	B-Application
variants	I-Application
and	O
invariants	O
.	O
</s>
<s>
In	O
other	O
cases	O
,	O
support	O
is	O
an	O
add-on	O
,	O
such	O
as	O
the	O
Java	B-Language
Modeling	I-Language
Language	I-Language
's	O
specification	O
for	O
in	O
Java	B-Language
.	O
</s>
<s>
Some	O
Lisp	B-Language
dialects	O
provide	O
an	O
extensive	O
sublanguage	O
for	O
describing	O
Loops	O
.	O
</s>
<s>
An	O
early	O
example	O
can	O
be	O
found	O
in	O
Conversional	O
Lisp	B-Language
of	O
Interlisp	B-Language
.	O
</s>
<s>
Common	B-Language
Lisp	I-Language
provides	O
a	O
Loop	O
macro	O
which	O
implements	O
such	O
a	O
sublanguage	O
.	O
</s>
<s>
while	O
(	O
true	O
)	O
does	O
not	O
count	O
as	O
an	O
infinite	B-Algorithm
loop	I-Algorithm
for	O
this	O
purpose	O
,	O
because	O
it	O
is	O
not	O
a	O
dedicated	O
language	O
structure	O
.	O
</s>
<s>
C	B-Language
's	O
for	O
(	O
init	O
;	O
test	O
;	O
increment	O
)	O
loop	O
is	O
a	O
general	O
loop	O
construct	O
,	O
not	O
specifically	O
a	O
counting	O
one	O
,	O
although	O
it	O
is	O
often	O
used	O
for	O
that	O
.	O
</s>
<s>
Deep	O
breaks	O
may	O
be	O
accomplished	O
in	O
APL	B-Language
,	O
C	B-Language
,	O
C++	B-Language
and	O
C#	B-Application
through	O
the	O
use	O
of	O
labels	O
and	O
gotos	O
.	O
</s>
<s>
Iteration	O
over	O
objects	O
was	O
in	O
PHP	B-Application
5	O
.	O
</s>
<s>
A	O
counting	O
loop	O
can	O
be	O
simulated	O
by	O
iterating	O
over	O
an	O
incrementing	O
list	O
or	O
generator	O
,	O
for	O
instance	O
,	O
Python	B-Language
's	O
range( )	O
.	O
</s>
<s>
Deep	O
breaks	O
may	O
be	O
accomplished	O
through	O
the	O
use	O
of	O
exception	B-General_Concept
handling	I-General_Concept
.	O
</s>
<s>
The	O
C++11	B-Language
standard	O
introduced	O
the	O
range-based	O
for	O
.	O
</s>
<s>
In	O
the	O
STL	B-Application
,	O
there	O
is	O
a	O
std::for_each	O
template	B-Application
function	O
which	O
can	O
iterate	O
on	O
STL	B-Application
containers	B-Application
and	O
call	O
a	O
unary	O
function	O
for	O
each	O
element	O
.	O
</s>
<s>
The	O
functionality	O
also	O
can	O
be	O
constructed	O
as	O
macro	O
on	O
these	O
containers	B-Application
.	O
</s>
<s>
Eiffel	B-Language
supports	O
a	O
reserved	O
word	O
retry	O
,	O
however	O
it	O
is	O
used	O
in	O
exception	B-General_Concept
handling	I-General_Concept
,	O
not	O
loop	O
control	O
.	O
</s>
<s>
Requires	O
Java	B-Language
Modeling	I-Language
Language	I-Language
(	O
JML	O
)	O
behavioral	O
interface	O
specification	O
language	O
.	O
</s>
<s>
Requires	O
loop	B-Application
variants	I-Application
to	O
be	O
integers	O
;	O
transfinite	O
variants	O
are	O
not	O
supported	O
.	O
</s>
<s>
D	B-Application
supports	O
infinite	O
collections	O
,	O
and	O
the	O
ability	O
to	O
iterate	O
over	O
those	O
collections	O
.	O
</s>
<s>
Deep	O
breaks	O
can	O
be	O
achieved	O
using	O
GO	B-Application
TO	O
and	O
procedures	O
.	O
</s>
<s>
Common	B-Language
Lisp	I-Language
predates	O
the	O
concept	O
of	O
generic	O
collection	O
type	O
.	O
</s>
<s>
Conditions	O
,	O
exceptions	B-General_Concept
and	O
continuations	O
are	O
three	O
common	O
sorts	O
of	O
non-local	O
control	O
constructs	O
;	O
more	O
exotic	O
ones	O
also	O
exist	O
,	O
such	O
as	O
generators	O
,	O
coroutines	B-Architecture
and	O
the	O
async	B-Operating_System
keyword	O
.	O
</s>
<s>
PL/I	B-Language
has	O
some	O
22	O
standard	O
conditions	O
(	O
e.g.	O
,	O
ZERODIVIDE	O
SUBSCRIPTRANGE	O
ENDFILE	O
)	O
which	O
can	O
be	O
raised	O
and	O
which	O
can	O
be	O
intercepted	O
by	O
:	O
ON	O
condition	O
action	O
;	O
Programmers	O
can	O
also	O
define	O
and	O
use	O
their	O
own	O
named	O
conditions	O
.	O
</s>
<s>
Like	O
the	O
unstructured	O
if	O
,	O
only	O
one	O
statement	O
can	O
be	O
specified	O
so	O
in	O
many	O
cases	O
a	O
GOTO	B-Application
is	O
needed	O
to	O
decide	O
where	O
flow	O
of	O
control	O
should	O
resume	O
.	O
</s>
<s>
Modern	O
languages	O
have	O
a	O
specialized	O
structured	O
construct	O
for	O
exception	B-General_Concept
handling	I-General_Concept
which	O
does	O
not	O
rely	O
on	O
the	O
use	O
of	O
GOTO	B-Application
or	O
(	O
multi-level	O
)	O
breaks	O
or	O
returns	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
C++	B-Language
one	O
can	O
write	O
:	O
</s>
<s>
If	O
there	O
is	O
no	O
catch	O
matching	O
a	O
particular	O
throw	O
,	O
control	O
percolates	O
back	O
through	O
subroutine	O
calls	O
and/or	O
nested	O
blocks	O
until	O
a	O
matching	O
catch	O
is	O
found	O
or	O
until	O
the	O
end	O
of	O
the	O
main	O
program	B-Application
is	O
reached	O
,	O
at	O
which	O
point	O
the	O
program	B-Application
is	O
forcibly	O
stopped	O
with	O
a	O
suitable	O
error	O
message	O
.	O
</s>
<s>
Via	O
C++'s	O
influence	O
,	O
catch	O
is	O
the	O
keyword	O
reserved	O
for	O
declaring	O
a	O
pattern-matching	B-Language
exception	B-General_Concept
handler	I-General_Concept
in	O
other	O
languages	O
popular	O
today	O
,	O
like	O
Java	B-Language
or	O
C#	B-Application
.	O
</s>
<s>
Some	O
other	O
languages	O
like	O
Ada	B-Language
use	O
the	O
keyword	O
exception	O
to	O
introduce	O
an	O
exception	B-General_Concept
handler	I-General_Concept
and	O
then	O
may	O
even	O
employ	O
a	O
different	O
keyword	O
(	O
when	O
in	O
Ada	B-Language
)	O
for	O
the	O
pattern	B-Language
matching	I-Language
.	O
</s>
<s>
A	O
few	O
languages	O
like	O
AppleScript	B-Application
incorporate	O
placeholders	O
in	O
the	O
exception	B-General_Concept
handler	I-General_Concept
syntax	O
to	O
automatically	O
extract	O
several	O
pieces	O
of	O
information	O
when	O
the	O
exception	O
occurs	O
.	O
</s>
<s>
This	O
approach	O
is	O
exemplified	O
below	O
by	O
the	O
on	O
error	O
construct	O
from	O
AppleScript	B-Application
:	O
</s>
<s>
David	O
Watt	O
's	O
2004	O
textbook	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
section	O
on	O
early	O
exits	O
from	O
loops	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	B-General_Concept
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	B-Application
unit	O
,	O
but	O
[	O
for	O
which ]	O
a	O
handler	O
is	O
more	O
naturally	O
located	O
in	O
a	O
high-level	O
program	B-Application
unit	O
"	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
program	B-Application
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	B-Application
and	O
thus	O
a	O
handling	O
routine	O
for	O
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>
Watt	O
notes	O
that	O
in	O
contrast	O
to	O
status	O
flags	O
testing	O
,	O
exceptions	B-General_Concept
have	O
the	O
opposite	O
default	B-General_Concept
behavior	I-General_Concept
,	O
causing	O
the	O
program	B-Application
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
explicit	O
code	O
to	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
are	O
not	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>
In	O
Object	B-Language
Pascal	I-Language
,	O
D	B-Application
,	O
Java	B-Language
,	O
C#	B-Application
,	O
and	O
Python	B-Language
a	O
finally	O
clause	O
can	O
be	O
added	O
to	O
the	O
try	O
construct	O
.	O
</s>
<s>
Since	O
this	O
pattern	O
is	O
fairly	O
common	O
,	O
C#	B-Application
has	O
a	O
special	O
syntax	O
:	O
</s>
<s>
Python	B-Language
's	O
with	O
statement	O
and	O
Ruby	B-Language
's	O
block	O
argument	O
to	O
File.open	O
are	O
used	O
to	O
similar	O
effect	O
.	O
</s>
<s>
All	O
the	O
languages	O
mentioned	O
above	O
define	O
standard	O
exceptions	B-General_Concept
and	O
the	O
circumstances	O
under	O
which	O
they	O
are	O
thrown	O
.	O
</s>
<s>
Users	O
can	O
throw	O
exceptions	B-General_Concept
of	O
their	O
own	O
;	O
in	O
fact	O
C++	B-Language
allows	O
users	O
to	O
throw	O
and	O
catch	O
almost	O
any	O
type	O
,	O
including	O
basic	O
types	O
like	O
int	O
,	O
whereas	O
other	O
languages	O
like	O
Java	B-Language
are	O
not	O
as	O
permissive	O
.	O
</s>
<s>
C#	B-Application
5.0	O
introduced	O
the	O
async	B-Operating_System
keyword	O
for	O
supporting	O
asynchronous	B-Architecture
I/O	I-Architecture
in	O
a	O
"	O
direct	O
style	O
"	O
.	O
</s>
<s>
Like	O
the	O
async	B-Operating_System
keyword	O
,	O
this	O
supports	O
programming	O
in	O
a	O
"	O
direct	O
style	O
"	O
.	O
</s>
<s>
Coroutines	B-Architecture
are	O
functions	O
that	O
can	O
yield	O
control	O
to	O
each	O
other	O
-	O
a	O
form	O
of	O
co-operative	B-Operating_System
multitasking	I-Operating_System
without	O
threads	O
.	O
</s>
<s>
Coroutines	B-Architecture
can	O
be	O
implemented	O
as	O
a	O
library	O
if	O
the	O
programming	O
language	O
provides	O
either	O
continuations	O
or	O
generators	O
-	O
so	O
the	O
distinction	O
between	O
coroutines	B-Architecture
and	O
generators	O
in	O
practice	O
is	O
a	O
technical	O
detail	O
.	O
</s>
<s>
In	O
a	O
spoof	O
Datamation	O
article	O
in	O
1973	O
,	O
R	O
.	O
Lawrence	O
Clark	O
suggested	O
that	O
the	O
GOTO	B-Application
statement	O
could	O
be	O
replaced	O
by	O
the	O
COMEFROM	B-Language
statement	O
,	O
and	O
provides	O
some	O
entertaining	O
examples	O
.	O
</s>
<s>
COMEFROM	B-Language
was	O
implemented	O
in	O
one	O
esoteric	O
programming	O
language	O
named	O
INTERCAL	B-Language
.	O
</s>
<s>
Donald	O
Knuth	O
's	O
1974	O
article	O
"	O
Structured	B-Language
Programming	I-Language
with	O
go	B-Application
to	O
Statements	O
"	O
,	O
identifies	O
two	O
situations	O
which	O
were	O
not	O
covered	O
by	O
the	O
control	O
structures	O
listed	O
above	O
,	O
and	O
gave	O
examples	O
of	O
control	O
structures	O
which	O
could	O
handle	O
these	O
situations	O
.	O
</s>
<s>
If	O
while	O
is	O
omitted	O
,	O
we	O
get	O
an	O
infinite	B-Algorithm
loop	I-Algorithm
.	O
</s>
<s>
In	O
Ada	B-Language
,	O
the	O
above	O
loop	O
construct	O
(	O
loop-while-repeat	O
)	O
can	O
be	O
represented	O
using	O
a	O
standard	O
infinite	B-Algorithm
loop	I-Algorithm
(	O
loop	O
-	O
end	O
loop	O
)	O
that	O
has	O
an	O
exit	O
when	O
clause	O
in	O
the	O
middle	O
(	O
not	O
to	O
be	O
confused	O
with	O
the	O
exitwhen	O
statement	O
in	O
the	O
following	O
section	O
)	O
.	O
</s>
<s>
exitwhen	O
is	O
conceptually	O
similar	O
to	O
exception	B-General_Concept
handling	I-General_Concept
,	O
and	O
exceptions	B-General_Concept
or	O
similar	O
constructs	O
are	O
used	O
for	O
this	O
purpose	O
in	O
many	O
languages	O
.	O
</s>
<s>
One	O
way	O
to	O
attack	O
a	O
piece	O
of	O
software	O
is	O
to	O
redirect	O
the	O
flow	O
of	O
execution	O
of	O
a	O
program	B-Application
.	O
</s>
<s>
A	O
variety	O
of	O
control-flow	O
integrity	O
techniques	O
,	O
including	O
stack	O
canaries	O
,	O
buffer	B-Error_Name
overflow	I-Error_Name
protection	I-Error_Name
,	O
shadow	O
stacks	O
,	O
and	O
vtable	B-Language
pointer	O
verification	O
,	O
are	O
used	O
to	O
defend	O
against	O
these	O
attacks	O
.	O
</s>
