3 ms·
Lisp hacker summary. Defunctionalization is the elimination of function objects (closures) from run-time representations. Functions that don't carry an enviro
by kazinator 7y ago
Lisp hacker summary.
Defunctionalization is the elimination of function objects (closures) from run-time representations.
Functions that don't carry an environment (such as global functions) can be replaced by symbols. For instance, a simple calculator's binding for the negation button - can use a symbol such as Negate instead of the #<closure> for the negation function.
Functions that carry and environment can be replaced by objects which represent that information with explicit properties. The object can somehow later be used as if it were a function anyway. (Either a closure can be made which references the object in its environment, or else the object itself can be callable like a function.)
These representations are more readable than #<closure> when debugging, usefully susceptible to manipulation by code, and susceptible to validation.