Previous: Recur, Up: Recursion


2.7.9.2 Refer

In the style of recursive programming compelled by the available meta primitive, a function effectively requires a copy of its own machine code as its left argument. Bringing about that state of affairs is an interesting party trick.

If we had a definition of bu in the standard library implying

T16
([[bu]] (f,k)) x = f(k,x)

which for the sake of concreteness can be done like this,

     bu = (hired compose)(
             left,
             (hired couple)(compose(constant,right),constant identity))

then a definition of refer as

     refer = (hired bu)(identity,identity)

would be consistent with the following property of the operator.

P15
([[refer]] f) x = f (f,x)

The proof, as always, is a matter of routine calculation in the manner of the section on how avram thinks.

However, this pattern would occur so frequently in recursively defined functions as to be a significant waste of space and time. Therefore, rather than requiring it to be defined in terms of other operations, the virtual machine specification recognizes a pattern of the form below with respect to property P15,

T17
[[refer]] f = (((f,nil),nil),nil)

and takes the property to be true by definition of the operator. A definition of refer consistent with T17 is therefore to be found in the standard library, not the definition proposed above.