> On Mar 4, 2018, at 15:11, Matthew Flatt <mfl...@cs.utah.edu> wrote:
> 
> I think scope-flipping would work, but FWIW, I thought you were going
> a different direction here. The scope-flipping approach is a way to
> infer an intended scope dynamically. It sounds to me like you want
> something more static --- a way of applying a fresh scope to a textual
> region of syntax literals.
> 
> An extreme end of that approach would be applying a fresh scope on the
> evaluation of each `quote-syntax` form (essentially as van Tonder
> explored), but it's possible that larger regions would work better.

Sam suggested I take a look at van Tonder’s work as well on Slack, and
it’s interesting, though it isn’t what I originally had in mind. I think
it would solve the first example of mine, but it would not solve the
second. In the second example, all uses of tmp come from the same
quote-syntax form, merely multiplied via ellipsis. My first mental model
was to treat syntax classes under ellipses like distinct macro
invocations, which would require a dynamic, not lexical, treatment of
scope to be consistent with Racket’s model of hygiene.

If I’m understanding correctly, attaching fresh scopes at quotation
rather than expansion treats the source text of the program as the
ground truth for all scoping information — if two identifiers come from
the same location in the user’s source code, they can bind each other.
This seems like a good model for most things, but it seems radically
different from Racket’s model when internal definitions are involved,
since such an interpretation would imply that this program should
produce a duplicate definition error:

    (define-syntax-rule (def-x)
      (define x 42))

    (def-x)
    (def-x)

That seems to me like an enormous break from Racket’s model of hygiene,
but it doesn’t seem wrong, just different. I could picture a different
programming language with a different macroexpander using such a model
successfully. Still, unless I’m misunderstanding the implications here,
it seems like attaching the scopes at expansion (even if “expansion” is
really “parsing with syntax classes”) rather than quoting would be more
consistent with the rest of Racket?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to