Hi all,

Some of my creative students came up with the following:

(let ([y 5])
 (begin
   (display y)
   (define y 10)
   y)))

which raises a mysterious
y: undefined;
 cannot use before initialization

I remember earlier discussion on this list about the fact that `define' was 
somehow “broken” for various cases of nesting, and that it was part of the 
motivation for coming up with `local’. Sure enough, the following works as 
expected:

(let ([y 5])
 (begin
   (display y)
   (local [(define y 10)]
     y)))

While I don’t intend to motivate my students to do funky let/define nesting, I 
would like to be able to explain why the error is raised. Any (sensible) 
explanation?

Thanks!

-- Éric

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to