Next: , Previous: , Up: compiler   [Index]


17.10 Optimisation of letrec and letrec* forms

Vicare’s compiler offers multiple algorithms to implement and optimise the core language forms letrec, letrec* and library-letrec*, whose syntax is:

(letrec ((?lhs ?rhs) ...) ?body)

(letrec* ((?lhs ?rhs) ...) ?body)

(library-letrec* ((?lhs ?loc ?rhs) ...) ?body)

notice that the ?body is a single form. The transformations for letrec* and library-letrec* are equal; the difference between the two lies in the implementation of allocations, references and assignments to the ?lhs.

When this compiler pass is applied to the recordised code, the forms have already been transformed into:

(recbind  ((?lhs ?rhs) ...) ?body)

(rec*bind ((?lhs ?rhs) ...) ?body)

where instances of the structure recbind represent letrec forms and instances of the structure rec*bind represent letrec* and library-letrec* forms.

After this compiler pass has been applied: recbind and rec*bind structs are no more present in the returned code, having been substituted with bind and fix structs. So in the returned code: every prelex struct represents a binding defined either by bind or fix.