What Is Defunctionalization?
Defunctionalization is a program transformation that eliminates higher-order functions by representing each function value as a distinct data constructor and routing all calls through one apply function that pattern matches on the constructor. The behavior that was a function becomes data plus a central dispatcher. The result is a first-order program with no function-valued arguments.
Why it matters
Defunctionalization lets higher-order code be compiled to languages or targets without first-class functions, and it makes the set of possible behaviors explicit. It is a useful technique in compilers and whole-program analyses.
Related guides
What Is Closure Conversion?Closure conversion is a compiler transformation that turns nested functions capturing variables into plain fu…
What Is a Higher-Order Function?A higher-order function takes other functions as arguments or returns a function as its result, treating beha…
What Is Pattern Matching?Pattern matching inspects a value against a set of shapes, selecting a branch and binding parts of the value…