Quote from SICP:
Internal definitions should be at the beginning of the procedure body. For the consequences of launching programs that mix definitions and their use, the administration is not responsible.
An example of the correct code
(define (sqrt x) (define (good-enough? guess) (< (abs (- (square guess) x)) 0.001)) (define (improve guess) (average guess (/ x guess))) (define (sqrt-iter guess) (if (good-enough? guess) guess (sqrt-iter (improve guess)))) (sqrt-iter 1.0)) Does this mean that I can't do this? -
(define (test x) (define (test2) (* xx)) (test2) (define (test3) (+ xx)) (test3)) Or is it implied that I should declare it before use?