[racket] Why is x can be simultenaously bind and not bind ?
On Sun, Sep 15, 2013 at 6:34 PM, Andre Mayers
<Andre.Mayers at usherbrooke.ca> wrote:
> Thank you for your answer. But it is still not clear.
>
>> (let ([x 'uuu])
>> (define x 'a)
>> x)
>
> This:
> 1. creates a binding [x => 'uuu]
> 2. creates a different binding [x => 'a] that shadows the existing binding
> of x
> 3. gives the value of the *visible* binding of x, namely 'a
>
> The two binding [x => 'uuu] and [x =>'a] are exactly in the same lexical
> space (the second binding is not in a lexical subspace) and that doesn't
> make sense for me.
No, they're not. As the reference says:
Definitions in an internal-definition context are equivalent
to local binding via letrec-syntaxes+values...[1]
> As far as I know, to shadow a binding, you have to create
> a lexical subspace. Am I wrong ?
You're not wrong about that, but an internal definition expands into a
letrec-syntaxes+values form, which does in fact create a new lexical
scope.
-Jon
[1] http://docs.racket-lang.org/reference/syntax-model.html?q=internal#%28part._intdef-body%29