[racket] macro masters needed! bound-identifier=? help for Racket / Rust

From: John Clements (clements at brinckerhoff.org)
Date: Tue Jul 23 14:52:04 EDT 2013

On Jul 23, 2013, at 2:44 PM, Matthew Flatt wrote:

> At Tue, 23 Jul 2013 14:24:10 -0400, John Clements wrote:
>> Welcome to DrRacket, version [3m].
>> Language: racket; memory limit: 512 MB.
>> expanded: '(let-values (((x) '19)) (let-values () x))
>> x-binding: .#<syntax:5:12 x>
>> x-use: .#<syntax:8:7 x>
>> free-id=? #t
>> bound-id=? #t
>> In particular, this result--that the binding instance of 'x' and the 
>> macro-introduced use of 'x' are *bound*-identifier=?--surprises me.
> It's because you're looking at a fully expanded form...
>> To take a step back, my low-level understanding
> All correct, as far as I can tell, at the point at which the `getx'
> macro has just been expanded. But the next step is to expand/parse `x',
> which doesn't just leave the `x' as it was; the `x' expands to an
> identifier for the binding of `x'.
> In MtWT, see the 7th rule for `expand', which says
> expand[[id, xi, Sigma]] = <id_new, Sigma>
>   where (Var id_new) = xi(resolve[[id, Sigma]])
> The `x' that you have in mind is `id', but the `x' you're checking with
> `build-identifier=?' is `id_new'.

Whew! okay, that makes sense. It also explains why xi carries around variable bindings. Now, I just need to think about how that applies to Rust.

Many thanks, especially for the swift response.


Posted on the users mailing list.