[racket] Definitions in cond-bodies
I have found an interesting program:
#lang racket
(let ([x 1])
(cond
[(= x 1)
(define u 2)
(+ u 1)]
[else u]))
When run gives a very reasonable error message:
expand: unbound identifier in module in: u
When
(let ([x 1])
(cond
[(= x 1)
(define u 2)
(+ u 1)]
[else u]))
is pasted into the interaction window, I get 3 !
I was expecting an error.
Welcome to DrRacket, version 5.3.0.6--2012-05-11(9401a53/a) [3m].
Language: racket; memory limit: 128 MB.
. expand: unbound identifier in module in: u
> (let ([x 1])
(cond
[(= x 1)
(define u 2)
(+ u 1)]
[else u]))
3