Next: , Previous: , Up: machinery continuations   [Index]


16.5.2 Subordinate function calls without continuations

We assume the validity of machinery simplifications to focus on some aspect of the runtime behaviour, Simplification assumptions. Let’s look at this simple program that does not create explicit continuations:

(import (rnrs))
(define (alpha) (beta))
(define (beta)  (delta))
(define (delta) 123)
(alpha)

Vicare allocates a memory segment to be used as stack, then executes the call to alpha pushing its stack frame on the stack; as subordinate function calls are performed: new stack frames are pushed on the stack, machinery continuations without.

        -- growing direction -->

|----------|---------------------------------------|
  locals of
  toplevel

|----------|----------|----------------------------|
  frame of  locals of
  toplevel    alpha

|----------|----------|----------|-----------------|
  frame of   frame of  locals of
  toplevel    alpha     beta

|----------|----------|----------|-----------|-----|
  frame of   frame of   frame of   locals of
  toplevel    alpha      beta       delta

Figure 16.15: Scheme stack segment after calling alpha, beta, delta.

When the functions return the stack rewinds; when there are no more stack frames: there is nowhere to return to, so the program terminates, machinery continuations without.

        <-- rewind direction --

|----------|----------|----------|-----------------|
  frame of   frame of   frame of
  toplevel    alpha      beta

|----------|----------|----------------------------|
  frame of   frame of
  toplevel    alpha

|----------|---------------------------------------|
  frame of
  toplevel

Figure 16.16: Scheme stack segment after returning from delta, beta, alpha.