[racket-dev] Strange issue with identifier-binding being wrong for lexical variables
At Wed, 22 Oct 2014 10:25:51 -0400, Sam Tobin-Hochstadt wrote:
> On Wed, Oct 22, 2014 at 10:20 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> > Expansions that produce this bad `identifier-binding` result probably
> > happen up all the time. They don't bother the bytecode compiler,
> > because the compiler uses `free-identifier=?` to compare bindings in
> > expanded code, keeping track of all of the bindings that are in the
> > environment of a given expression. Depending on your use case, that
> > might be the way to go for now.
>
> If I understand correctly, I should maintain an environment of
> lexically-bound identifiers at every point, and if a given identifier
> is in that environment, it should be treated as lexical, even if
> `identifier-binding` says that it's a module-bound variable. Only if
> an identifier isn't currently bound should I treat it as a
> module-bound variable.
>
> Does that sound right? This would be easy enough for me to do.
Yes, that's right.