[racket] (define (f (x y)) body) when y has a previous definition
I was answering this Stack Overflow question [1], and came across this
bizarre (to me, anyhow) behavior (REPL transcript from Dr.Racket)
Welcome to DrRacket, version 5.3 [3m].
Language: racket; memory limit: 128 MB.
> (define y 2)
> (define (f (x y))
(print x)
(print y))
> (f 1)
12
Is this expected? If y isn't defined previously, then the definition
is accepted in the REPL, but trying to call (f 1) results in an error:
Welcome to DrRacket, version 5.3 [3m].
Language: racket; memory limit: 128 MB.
> (define (f (x y))
(print x)
(print y))
> (f 1)
1. . y: undefined;
cannot reference an identifier before its definition
Putting the definition in the definitions pane and Ctrl-R / Racket>Run
gives an error:
(X). y: unbound identifier in module in: y
What's going on here? The definition doesn't seem to be a legal form
based on the syntax given in the documentation, but the system's still
accepting it, and with varying behaviors.
//JT
[1] http://stackoverflow.com/q/24365591/1281433
--
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/