constant applicative form
constant applicative form
(functional programming)Since a CAF is a supercombinator, it contains no freevariables. Moreover, since it is not a lambda abstraction itcontains no variables at all. It may however containidentifiers which refer to other CAFs, e.g.
c 3 where c = (* 2).
A CAF can always be lifted to the top level of the program.It can either be compiled to a piece of graph which will beshared by all uses or to some shared code which will overwriteitself with some graph the first time it is evaluated. A CAFsuch as
ints = from 1 where from n = n : from (n+1)
can grow without bound but may only be accessible from withinthe code of one or more functions. In order for the garbage collector to be able to reclaim such structures, we associatewith each function a list of the CAFs to which it refers.When garbage collecting a reference to the function we collectthe CAFs on its list.
[The Implementation of Functional Programming Languages, Simon Peyton Jones].