Take the following function definition as my example:
(define (foo)
(bar)
(define (bar)
(display "bar")))
This would produce an error: ;Premature reference to reserved name: bar
. On the contrary, the following two definitions are legitimate. Note that I'm using premature reference in both of them.
(define (foo)
(bar))
(define (bar)
(display "bar"))
(define (foo)
(define (bar)
(display "bar"))
(bar))
My question is: why can't I prematurely reference a currently undefined function when using block structure? And why is bar
a "reserved name"?