constant applicative form

constant applicative form

(functional programming)(CAF) A supercombinator which isnot a lambda abstraction. This includes truly constantexpressions such as 12, (+ 1 2), [1, 2, 3] as well as partiallyapplied functions such as (+ 4). Note that this last exampleis equivalent under eta abstraction to \\ x . + 4 x which isnot a CAF.

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].