Next: Building Closures, Previous: Principles of Compilation, Up: Principles of Compilation [Contents][Index]
For example, ‘(a , x) will be converted to (cons ’a (cons x ’())).
(define (foo x) …)
are converted to defines with the essential syntax
(define foo (lambda (x) …))
Non-top-level defines are converted into equivalent letrec-s.
(define (foo x y)
(let ((x y)
(z x))
(let* ((x (+ z x)))
x)))
is converted to
(define foo
(lambda (x y)
(let* ((x__1 y)
(z x)
(x__2 (+ z x__1)))
x__2)))
Thus letrec-s are split into ordered chunks using dependency analysis and topological sorting, to reduce the number of mutually passed variables. Wherever possible, letrec-s are replaced by let*-s inside these chunks.
cond, case, or,
and into equivalent terms using a small set of primitives. New
variables may be introduced in this phase.
In case a procedure like or or and occurs in the place
where its value is treated as a boolean (eg. first argument of
if), it is converted into an analogous boolean-returning
procedure, which will finally be represented by an analogous C
procedure (eg. || or &&).
Associative procedures are converted into structures of corresponding nonassociative procedures. List is converted to a structure of cons-s.
Map and for-each with more than two arguments are converted into an equivalent do-cycle. map-s and for-each-s with two arguments are treated as if they were defined in the compiled file – the definitions map1 and for-each1 are automatically included, if needed.
There is an option in hobbit.scm to make all map-s and for-each-s be converted into equivalent do-loops, avoiding the use of map1 and/or for-each1 altogether.
Criterias for HOP clonability are given in the section 6.4.
Liftability analysis follows the criterias given in section 6.5 and 6.6.
Next: Building Closures, Previous: Principles of Compilation, Up: Principles of Compilation [Contents][Index]