SICP — Scheme/JS Structure and Interpretation of Computer Programs — Comparison Edition

[1] In a real program we would probably use the block structure introduced in the last section to hide the definition of fact-iter: definition of fact_iter:
Original Python
(define (factorial n) (define (iter product counter) (if (> counter n) product (iter (* counter product) (+ counter 1)))) (iter 1 1)) def factorial(n): def iterate(product, counter): return (product if counter > n else iterate(counter * product, counter + 1)) return iterate(1, 1)
We avoided doing this here so as to minimize the number of things to think about at once.
[2] When we discuss the implementation of procedures functions on register machines in chapter 5, we will see that any iterative process can be realized in hardware as a machine that has a fixed set of registers and no auxiliary memory. In contrast, realizing a recursive process requires a machine that uses an auxiliary data structure known as a stack.
[3] Tail recursion has long been known as a compiler optimization trick. A coherent semantic basis for tail recursion was provided by Carl Hewitt (1977), who explained it in terms of the message-passing model of computation that we shall discuss in chapter 3. Inspired by this, Gerald Jay Sussman and Guy Lewis Steele Jr. (see Steele 1975) constructed a tail-recursive interpreter for Scheme. Steele later showed how tail recursion is a consequence of the natural way to compile procedure calls (Steele 1977). The IEEE standard for Scheme requires that Scheme implementations be tail-recursive.
[4] Tail recursion has long been known as a compiler optimization trick. A coherent semantic basis for tail recursion was provided by Carl Hewitt (1977), who explained it in terms of the message-passing model of computation that we shall discuss in chapter 3. Inspired by this, Gerald Jay Sussman and Guy Lewis Steele Jr. (see Steele 1975) constructed a tail-recursive interpreter for Scheme. Steele later showed how tail recursion is a consequence of the natural way to compile function calls (Steele 1977). The IEEE standard for Scheme requires that Scheme implementations be tail-recursive. The Python Language Reference does not specify tail recursion, one way or the other. While most implementations of Python are not tail-recursive, we assume in this book an implementation that is.
[5] Exercise 4.7 explores Python's while loops as syntactic sugar for functions that give rise to iterative processes. The full language Python, like other conventional languages, features a plethora of syntactic forms, all of which can be expressed more uniformly in the language Lisp.
1.2.1  Linear Recursion and Iteration