<< Previous exercise (5.25) | Index | Next exercise (5.27) >>
By the way, the maximum depth is not constant with Normal application: ┌───────────────────────┬──────────────────┬──────────────────┐ │ │ Maximum Depth │ Number of Pushes │ ├───────────────────────┼──────────────────┼──────────────────┤ │ Factorial Applicative │ 0n + 10 │ 35n + 35 │ ├───────────────────────┼──────────────────┼──────────────────┤ │ Factorial Normal │ 6n + 3 │ 50n + 48 │ └───────────────────────┴──────────────────┴──────────────────┘ The stack does not grow during the construction of the answer, instead the answer contains nested thunks. So I think forcing the answer to an actual value causes recursive calls to actual-value, eval-dispatch, and force-it, which grows the stack. Of course a better design than mine might eliminate this, especially if we didn't have memoization.
meteorgan