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

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Jul 23 14:44:59 EDT 2013

At Tue, 23 Jul 2013 14:24:10 -0400, John Clements wrote:
> Welcome to DrRacket, version 5.3.5.900 [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'.

Posted on the users mailing list.