In DrRacket, when I set the language to R5RS and run the following code:
(lambda (x) z)
it runs without error and returns #<procedure>
. This makes sense to me; the lambda form defines a procedure whose body has not yet been evaluated, and so that procedure is returned.
Alternatively, when I use the Racket language dialect, I get the following error:
z: unbound identifier in module in: z
I don't understand why Racket is producing this error. I mean, of course I see that z
is undefined, but my understanding of the evaluation model is that the body of the function is not evaluated at the time of the function definition. That's consistent with the R5RS result, but not with the Racket result. What is Racket doing here, precisely? Is it "peeking" in some way in the body of the code to see if the variables are defined? What is different in the evaluation model from R5RS that results in this different behavior?