Racket and unrelated identifier in lambda expression, contrast with r5rs

In DrRacket, when I install the language in R5RS and run the following code:

(lambda (x) z)

It works without errors and returns #<procedure>. It makes sense to me; the lambda shape defines a procedure whose body has not yet been evaluated, and therefore the procedure returns.

Alternatively, when I use the Racket language dialect, I get the following error:

z: unbound identifier in module in: z

I do not understand why Racket produces this error. I mean, of course, I see that it is zundefined, but my understanding of the evaluation model is that the body of the function is not evaluated during the definition of the function. This is consistent with the result of R5RS, but not with the result of Racket. What is racket here, exactly? Is it "peeking" somehow in the body of the code to determine if variables are defined? What is the difference between the assessment model and R5RS, which leads to this other behavior?

+4
source share
2 answers

A #langfile is a module. The specification of extension and evaluation of modules is described in detail in the documentation. After some digging, I found this note:

. . .

" ". , .

, , repl, , "" . . , . , .

, , .

REPL . https://gist.github.com/samth/3083053

+5

Racket

#lang racket
(define f (lambda (x) z))

:

z: unbound identifier in module in: z

REPL:

Welcome to DrRacket, version 6.1.1 [3m].
Language: racket; memory limit: 128 MB.
> (define f (lambda (x) z))
> 

.

z :

#lang racket
(define f (lambda (x) z))
(define z 5)

.

, Racket , , REPL. , .

+4

All Articles