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


16 Introduction to execution machinery

The execution machinery of compiled Scheme code is a bit intricated when compared with the execution of, say, “normal” compiled C code; this is because the following features must be implemented:

Closures

Scheme functions are not just blocks of machine code: they are allowed to reference variable values captured at run time. Multiple closures (referencing different instances of the same semantic variables) can share the same block of machine code. Multiple closures (referencing different blocks of machine code) can share the same variable values. Closure objects.

Tail calls

Whenever a Scheme function call happens in tail position: it must be implemented in such a way that no new stack frame is created for the callee function; rather the stack frame of the caller is destroyed and reused as callee’s frame. This allows the use of tail calls as proper idiom to implement all the execution loops, even when such loops have an “infinite” number of iterations, without the risk of overflowing the Scheme stack.

Continuations

Scheme code is allowed to save the current continuation and resume it later any number of times.


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