[racket] Understanding lexical context

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Tue Oct 1 14:48:27 EDT 2013

On Tue, Oct 1, 2013 at 2:42 PM, Greg Hendershott
<greghendershott at gmail.com> wrote:
>
> 2. Plus it seems like it would be really unfortunate if carefully
> choosing one of #'a or #'b were required -- because that would mean
> `inner` couldn't be written to be usable by other macros independent
> of knowing the origin of what they give to `inner`, right?  I mean,
> without knowing if a comes from `outer` or from the usage of `outer`,
> and likewise for b, and therefore which of a or b to choose carefully.

Carefully choosing one _is_ required, and it _is_ really unfortunate.

This is, in essence, why unhygenic macros are bad for composition. You
have to pick something as the lexical context of your identifiers, and
your choices are limited to (a) one of the syntax objects in your
input or (b) whatever the previous expansion step was (that's what
syntax-local-introduce does). Therefore, it's hard to compose them
because they have to have a specific protocol for choosing identifier
contexts, and if the protocols don't line up, everything becomes much
more painful.

Sam

Posted on the users mailing list.