<s>
In	O
programming	O
languages	O
,	O
defunctionalization	B-Application
is	O
a	O
compile-time	B-Application
transformation	O
which	O
eliminates	O
higher-order	B-Language
functions	I-Language
,	O
replacing	O
them	O
by	O
a	O
single	O
first-order	O
apply	O
function	O
.	O
</s>
<s>
The	O
technique	O
was	O
first	O
described	O
by	O
John	O
C	O
.	O
Reynolds	O
in	O
his	O
1972	O
paper	O
,	O
"	O
Definitional	O
Interpreters	B-Application
for	O
Higher-Order	O
Programming	O
Languages	O
"	O
.	O
</s>
<s>
In	O
such	O
situations	O
,	O
defunctionalization	B-Application
must	O
be	O
preceded	O
by	O
closure	B-Application
conversion	I-Application
(	O
lambda	B-Application
lifting	I-Application
)	O
,	O
so	O
that	O
any	O
free	O
variables	O
of	O
a	O
function	O
abstraction	O
are	O
passed	O
as	O
extra	O
arguments	O
to	O
apply	O
.	O
</s>
<s>
In	O
addition	O
,	O
if	O
closures	B-Language
are	O
supported	O
as	O
first-class	O
values	O
,	O
it	O
becomes	O
necessary	O
to	O
represent	O
these	O
captured	O
bindings	O
by	O
creating	O
data	O
structures	O
.	O
</s>
<s>
Alternatively	O
,	O
the	O
target	O
language	O
may	O
support	O
indirect	O
calls	O
through	O
function	B-Language
pointers	I-Language
,	O
which	O
may	O
be	O
more	O
efficient	O
and	O
extensible	O
than	O
a	O
dispatch-based	O
approach	O
.	O
</s>
<s>
Besides	O
its	O
use	O
as	O
a	O
compilation	O
technique	O
for	O
higher-order	O
functional	B-Language
languages	I-Language
,	O
defunctionalization	B-Application
has	O
been	O
studied	O
(	O
particularly	O
by	O
Olivier	O
Danvy	O
and	O
collaborators	O
)	O
as	O
a	O
way	O
of	O
mechanically	O
transforming	O
interpreters	B-Application
into	O
abstract	B-Application
machines	I-Application
.	O
</s>
<s>
Defunctionalization	B-Application
is	O
also	O
related	O
to	O
the	O
technique	O
from	O
object-oriented	B-Language
programming	I-Language
of	O
representing	O
functions	O
by	O
function	B-Language
objects	I-Language
(	O
as	O
an	O
alternative	O
to	O
closures	B-Language
)	O
.	O
</s>
<s>
We	O
defunctionalize	O
by	O
replacing	O
all	O
higher-order	B-Language
functions	I-Language
(	O
in	O
this	O
case	O
,	O
o	O
is	O
the	O
only	O
higher-order	B-Language
function	I-Language
)	O
with	O
a	O
value	O
of	O
the	O
Lam	O
datatype	O
,	O
and	O
instead	O
of	O
calling	O
them	O
directly	O
,	O
we	O
introduce	O
an	O
apply	O
function	O
that	O
interprets	O
the	O
datatype	O
:	O
</s>
