<s>
In	O
computer	B-General_Concept
programming	I-General_Concept
,	O
a	O
return	B-Language
statement	I-Language
causes	O
execution	B-General_Concept
to	O
leave	O
the	O
current	O
subroutine	O
and	O
resume	O
at	O
the	O
point	O
in	O
the	O
code	O
immediately	O
after	O
the	O
instruction	O
which	O
called	O
the	O
subroutine	O
,	O
known	O
as	O
its	O
return	B-Language
address	I-Language
.	O
</s>
<s>
The	O
return	B-Language
address	I-Language
is	O
saved	O
by	O
the	O
calling	O
routine	O
,	O
today	O
usually	O
on	O
the	O
process	B-Operating_System
's	O
call	B-General_Concept
stack	I-General_Concept
or	O
in	O
a	O
register	B-General_Concept
.	O
</s>
<s>
Return	B-Language
statements	I-Language
in	O
many	O
programming	O
languages	O
allow	O
a	O
function	O
to	O
specify	O
a	O
return	B-Language
value	I-Language
to	O
be	O
passed	O
back	O
to	O
the	O
code	O
that	O
called	O
the	O
function	O
.	O
</s>
<s>
In	O
C	B-Language
and	O
C++	B-Language
,	O
return	O
exp	O
;	O
(	O
where	O
exp	O
is	O
an	O
expression	O
)	O
is	O
a	O
statement	O
that	O
tells	O
a	O
function	O
to	O
return	O
execution	B-General_Concept
of	O
the	O
program	O
to	O
the	O
calling	O
function	O
,	O
and	O
report	O
the	O
value	O
of	O
exp	O
.	O
</s>
<s>
If	O
a	O
function	O
has	O
the	O
return	O
type	O
void	O
,	O
the	O
return	B-Language
statement	I-Language
can	O
be	O
used	O
without	O
a	O
value	O
,	O
in	O
which	O
case	O
the	O
program	O
just	O
breaks	O
out	O
of	O
the	O
current	O
function	O
and	O
returns	O
to	O
the	O
calling	O
one	O
.	O
</s>
<s>
In	O
Pascal	B-Application
there	O
is	O
no	O
return	B-Language
statement	I-Language
.	O
</s>
<s>
(	O
However	O
,	O
in	O
newer	O
Pascals	B-Application
,	O
the	O
Exit(exp )	O
;	O
can	O
be	O
used	O
to	O
return	O
a	O
value	O
immediately	O
.	O
</s>
<s>
A	O
subroutine	O
automatically	O
returns	O
when	O
execution	B-General_Concept
reaches	O
its	O
last	O
executable	O
statement	O
.	O
</s>
<s>
Values	O
may	O
be	O
returned	O
by	O
assigning	O
to	O
an	O
identifier	O
that	O
has	O
the	O
same	O
name	O
as	O
the	O
subroutine	O
,	O
a	O
function	O
in	O
Pascal	B-Application
terminology	O
.	O
</s>
<s>
This	O
way	O
the	O
function	O
identifier	O
is	O
used	O
for	O
recursive	O
calls	O
and	O
as	O
result	O
holder	O
;	O
this	O
is	O
syntactically	O
similar	O
to	O
an	O
explicit	O
output	B-Operating_System
parameter	O
.	O
</s>
<s>
The	O
same	O
syntax	O
is	O
used	O
in	O
Fortran	O
66	O
and	O
Fortran	O
77	O
although	O
a	O
return	B-Language
statement	I-Language
was	O
added	O
in	O
FORTRAN	O
II	O
.	O
</s>
<s>
Oberon	B-Language
(	O
Oberon-07	O
)	O
has	O
a	O
return	O
clause	O
instead	O
of	O
a	O
return	B-Language
statement	I-Language
.	O
</s>
<s>
This	O
enables	O
compile-time	O
checking	O
of	O
proper	O
return	O
and	O
return	B-Language
value	I-Language
from	O
the	O
procedure	O
.	O
</s>
<s>
Some	O
expression-oriented	O
programming	O
language	O
,	O
such	O
as	O
Lisp	B-Language
,	O
Perl	B-Language
and	O
Ruby	B-Language
,	O
allow	O
the	O
programmer	O
to	O
omit	O
an	O
explicit	O
return	B-Language
statement	I-Language
,	O
specifying	O
instead	O
that	O
the	O
last	O
evaluated	O
expression	O
is	O
the	O
return	B-Language
value	I-Language
of	O
the	O
subroutine	O
.	O
</s>
<s>
In	O
other	O
cases	O
a	O
Null	O
value	O
is	O
returned	O
if	O
there	O
is	O
no	O
explicit	O
return	B-Language
statement	I-Language
:	O
in	O
Python	B-Language
,	O
the	O
value	O
None	O
is	O
returned	O
when	O
the	O
return	B-Language
statement	I-Language
is	O
omitted	O
,	O
while	O
in	O
JavaScript	B-Language
the	O
value	O
undefined	O
is	O
returned	O
.	O
</s>
<s>
In	O
Windows	B-Application
PowerShell	I-Application
all	O
evaluated	O
expressions	O
which	O
are	O
not	O
captured	O
(	O
e.g.	O
,	O
assigned	O
to	O
a	O
variable	O
,	O
cast	O
to	O
void	O
or	O
piped	B-Operating_System
to	O
$null	B-Operating_System
)	O
are	O
returned	O
from	O
the	O
subroutine	O
as	O
elements	O
in	O
an	O
array	O
,	O
or	O
as	O
a	O
single	O
object	O
in	O
the	O
case	O
that	O
only	O
one	O
object	O
has	O
not	O
been	O
captured	O
.	O
</s>
<s>
In	O
Perl	B-Language
,	O
a	O
return	B-Language
value	I-Language
or	O
values	O
of	O
a	O
subroutine	O
can	O
depend	O
on	O
the	O
context	O
in	O
which	O
it	O
was	O
called	O
.	O
</s>
<s>
The	O
most	O
fundamental	O
distinction	O
is	O
a	O
scalar	O
context	O
where	O
the	O
calling	O
code	O
expects	O
one	O
value	O
,	O
a	O
list	O
context	O
where	O
the	O
calling	O
code	O
expects	O
a	O
list	O
of	O
values	O
and	O
a	O
void	O
context	O
where	O
the	O
calling	O
code	O
does	O
n't	O
expect	O
any	O
return	B-Language
value	I-Language
at	O
all	O
.	O
</s>
<s>
Many	O
operating	B-General_Concept
systems	I-General_Concept
let	O
a	O
program	O
return	O
a	O
result	O
(	O
separate	O
from	O
normal	O
output	B-Operating_System
)	O
when	O
its	O
process	B-Operating_System
terminates	B-Operating_System
;	O
these	O
values	O
are	O
referred	O
to	O
as	O
return	B-Application
codes	I-Application
,	O
or	O
more	O
specifically	O
exit	B-Operating_System
statuses	I-Operating_System
.	O
</s>
<s>
From	O
within	O
the	O
program	O
this	O
return	O
is	O
typically	O
achieved	O
by	O
calling	O
Exit	O
(	O
system	O
call	O
)	O
(	O
common	O
even	O
in	O
C	B-Language
,	O
where	O
the	O
alternative	O
mechanism	O
of	O
returning	O
from	O
the	O
main	B-Language
function	I-Language
is	O
available	O
)	O
.	O
</s>
<s>
Return	B-Language
statements	I-Language
come	O
in	O
many	O
shapes	O
.	O
</s>
<s>
in	O
Java	B-Language
and	O
C#	B-Application
,	O
not	O
permitted	O
if	O
function	O
is	O
value-returning	O
BASIC	O
RETURN	O
Lisp	B-Language
(	O
return	B-Language
value	I-Language
)	O
last	O
statement	O
value	O
Perl	B-Language
,	O
Ruby	B-Language
return	O
@values	O
;	O
</s>
<s>
or	O
a	O
contextual	O
return	O
sequence	O
last	O
statement	O
value	O
PL/I	B-Language
return(expression )	O
;	O
</s>
<s>
In	O
some	O
assembly	B-Language
languages	I-Language
,	O
for	O
example	O
that	O
for	O
the	O
MOS	B-General_Concept
Technology	I-General_Concept
6502	I-General_Concept
,	O
the	O
mnemonic	O
"	O
RTS	O
"	O
(	O
ReTurn	O
from	O
Subroutine	O
)	O
is	O
used	O
.	O
</s>
<s>
Languages	O
with	O
an	O
explicit	O
return	B-Language
statement	I-Language
create	O
the	O
possibility	O
of	O
multiple	O
return	B-Language
statements	I-Language
in	O
the	O
same	O
function	O
.	O
</s>
<s>
Strong	O
adherents	O
of	O
structured	B-Language
programming	I-Language
make	O
sure	O
each	O
function	O
has	O
a	O
single	O
entry	O
and	O
a	O
single	O
exit	O
(	O
SESE	O
)	O
.	O
</s>
<s>
It	O
has	O
thus	O
been	O
argued	O
that	O
one	O
should	O
eschew	O
the	O
use	O
of	O
the	O
explicit	O
return	B-Language
statement	I-Language
except	O
at	O
the	O
textual	O
end	O
of	O
a	O
subroutine	O
,	O
considering	O
that	O
,	O
when	O
it	O
is	O
used	O
to	O
"	O
return	O
early	O
"	O
,	O
it	O
may	O
suffer	O
from	O
the	O
same	O
sort	O
of	O
problems	O
that	O
arise	O
for	O
the	O
GOTO	B-Application
statement	O
.	O
</s>
<s>
Conversely	O
,	O
it	O
can	O
be	O
argued	O
that	O
using	O
the	O
return	B-Language
statement	I-Language
is	O
worthwhile	O
when	O
the	O
alternative	O
is	O
more	O
convoluted	O
code	O
,	O
such	O
as	O
deeper	O
nesting	O
,	O
harming	O
readability	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>
Furthermore	O
,	O
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
"	O
sequencer	B-Language
that	O
terminates	B-Operating_System
execution	B-General_Concept
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>
Watt	O
also	O
examines	O
how	O
exception	O
sequencers	O
differ	O
from	O
escape	O
and	O
jump	O
sequencers	O
;	O
for	O
details	O
on	O
this	O
see	O
the	O
article	O
on	O
structured	B-Language
programming	I-Language
.	O
</s>
<s>
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
for	O
several	O
simple	O
problems	O
in	O
a	O
language	O
like	O
Pascal	B-Application
,	O
which	O
does	O
n't	O
allow	O
multiple	O
exit	O
points	O
.	O
</s>
<s>
For	O
the	O
problem	O
of	O
writing	O
a	O
function	O
to	O
linearly	O
searching	O
an	O
element	O
in	O
an	O
array	O
,	O
a	O
1980	O
study	O
by	O
Henry	O
Shapiro	O
(	O
cited	O
by	O
Roberts	O
)	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>
Others	O
,	O
including	O
Kent	O
Beck	O
and	O
Martin	O
Fowler	O
argue	O
that	O
one	O
or	O
more	O
guard	B-Language
clauses	I-Language
--	O
conditional	O
"	O
early	O
exit	O
"	O
return	B-Language
statements	I-Language
near	O
the	O
beginning	O
of	O
a	O
function	O
--	O
often	O
make	O
a	O
function	O
easier	O
to	O
read	O
than	O
the	O
alternative	O
.	O
</s>
<s>
For	O
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
which	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
do	O
n't	O
have	O
this	O
problem	O
.	O
</s>
<s>
Some	O
languages	O
,	O
such	O
as	O
C++	B-Language
and	O
Python	B-Language
,	O
employ	O
concepts	O
which	O
allow	O
actions	O
to	O
be	O
performed	O
automatically	O
upon	O
return	O
(	O
or	O
exception	O
throw	O
)	O
which	O
mitigates	O
some	O
of	O
these	O
issues	O
–	O
these	O
are	O
often	O
known	O
as	O
"	O
try/finally	O
"	O
or	O
similar	O
.	O
</s>
<s>
Functionality	O
like	O
these	O
"	O
finally	O
"	O
clauses	O
can	O
be	O
implemented	O
by	O
a	O
goto	B-Application
to	O
the	O
single	O
return	O
point	O
of	O
the	O
subroutine	O
.	O
</s>
<s>
An	O
alternative	O
solution	O
is	O
to	O
use	O
the	O
normal	O
stack	O
unwinding	O
(	O
variable	O
deallocation	O
)	O
at	O
function	O
exit	O
to	O
unallocate	O
resources	O
,	O
such	O
as	O
via	O
destructors	O
on	O
local	O
variables	O
,	O
or	O
similar	O
mechanisms	O
such	O
as	O
Python	B-Language
's	O
"	O
with	O
"	O
statement	O
.	O
</s>
<s>
Some	O
early	O
implementations	O
of	O
languages	O
such	O
as	O
the	O
original	O
Pascal	B-Application
and	O
C	B-Language
restricted	O
the	O
types	O
that	O
can	O
be	O
returned	O
by	O
a	O
function	O
(	O
e.g.	O
,	O
not	O
supporting	O
record	O
or	O
struct	B-Language
types	O
)	O
to	O
simplify	O
their	O
compilers	B-Language
.	O
</s>
<s>
In	O
Java	B-Language
—	O
and	O
similar	O
languages	O
modeled	O
after	O
it	O
,	O
like	O
JavaScript	B-Language
—	O
it	O
is	O
possible	O
to	O
execute	O
code	O
even	O
after	O
return	B-Language
statement	I-Language
,	O
because	O
the	O
finally	O
block	O
of	O
a	O
try-catch	B-General_Concept
structure	I-General_Concept
is	O
always	O
executed	O
.	O
</s>
<s>
So	O
if	O
the	O
return	B-Language
statement	I-Language
is	O
placed	O
somewhere	O
within	O
try	O
or	O
catch	O
blocks	O
the	O
code	O
within	O
finally	O
(	O
if	O
added	O
)	O
will	O
be	O
executed	O
.	O
</s>
<s>
It	O
is	O
even	O
possible	O
to	O
alter	O
the	O
return	B-Language
value	I-Language
of	O
a	O
non	O
primitive	O
type	O
(	O
a	O
property	O
of	O
an	O
already	O
returned	O
object	O
)	O
because	O
the	O
exit	O
occurs	O
afterwards	O
as	O
well	O
.	O
</s>
<s>
Cousin	O
to	O
return	B-Language
statements	I-Language
are	O
yield	B-Architecture
statements	I-Architecture
:	O
where	O
a	O
return	O
causes	O
a	O
subroutine	O
to	O
terminate	B-Operating_System
,	O
a	O
yield	O
causes	O
a	O
coroutine	B-Architecture
to	O
suspend	O
.	O
</s>
<s>
The	O
coroutine	B-Architecture
will	O
later	O
continue	O
from	O
where	O
it	O
suspended	O
if	O
it	O
is	O
called	O
again	O
.	O
</s>
<s>
Coroutines	B-Architecture
are	O
significantly	O
more	O
involved	O
to	O
implement	O
than	O
subroutines	O
,	O
and	O
thus	O
yield	B-Architecture
statements	I-Architecture
are	O
less	O
common	O
than	O
return	B-Language
statements	I-Language
,	O
but	O
they	O
are	O
found	O
in	O
a	O
number	O
of	O
languages	O
.	O
</s>
<s>
The	O
RETURN	B-Language
instruction	I-Language
pops	O
the	O
return	B-Language
address	I-Language
from	O
the	O
stack	O
into	O
the	O
instruction	O
pointer	O
and	O
execution	B-General_Concept
resumes	O
at	O
that	O
address	O
.	O
</s>
<s>
The	O
CALL	O
instruction	O
places	O
address	O
of	O
the	O
next	O
instruction	O
in	O
a	O
register	B-General_Concept
and	O
branches	O
to	O
the	O
specified	O
address	O
.	O
</s>
<s>
The	O
RETURN	B-Language
instruction	I-Language
sequence	O
places	O
the	O
return	B-Language
address	I-Language
from	O
the	O
register	B-General_Concept
into	O
the	O
instruction	O
pointer	O
and	O
execution	B-General_Concept
resumes	O
at	O
that	O
address	O
.	O
</s>
<s>
The	O
RETURN	B-Language
instruction	I-Language
sequence	O
branches	O
to	O
the	O
return	B-Language
address	I-Language
by	O
an	O
indirect	O
jump	O
to	O
the	O
first	O
instruction	O
of	O
the	O
subroutine	O
.	O
</s>
