> On Dec 13, 2016, at 11:23 AM, 'William J. Bowman' via Racket Users
> <racket-users@googlegroups.com> wrote:
> 
> Notice that #'x is not the same identifier as x, and thus does not
> have the same syntax-properties.

I’m not convinced this is correct.

If you insert println statements in the body of define^, inside the
with-syntax block, you get the following:

  (println (syntax-property #'x 'definition))
  (println (syntax-property-preserved? #'x 'definition))

  ; => #<syntax:format-id1.rkt:49:12 id^>
  ; => #t

The syntax properties are definitely maintained in templates used
by `syntax`.

> Why does this issue only comes up across a file boundary? I suspect
> this has to do with the behavior of make-rename-transformer. Since
> #'x was not getting 'not-free-identifier=? correctly,
> make-rename-transformer was optimizing this away, although I thought
> I was preventing that.

This is more interesting, and it was my first instinct, too. For
that reason, I replaced uses of make-rename-transformer with uses
of make-variable-like-transformer from syntax/transformer, but the
behavior was the same, so I don’t think this has to do with
make-rename-transformer specifically. However, something more
interesting happens.

I changed the macro that define^ defines to insert some debugging
calls on macro invocation:

  (define-syntax (id stx)
    (println (syntax-property #'x 'definition))
    (println (syntax-property-preserved? #'x 'definition))
    ((set!-transformer-procedure
      (make-variable-like-transformer #'x))
     stx))

The output of this is much more interesting. When running the source
module, format-id1.rkt, the result is as one would expect:

  ; => #<syntax:format-id1.rkt:49:12 id^>
  ; => #t

However, when using the defined identifier from format-id2.rkt, the
result is different:

  ; => #f
  ; => #f

This is extremely interesting, since the first example demonstrates
that the syntax property is most definitely marked as preserved,
yet it gets lost by the time format-id2 tries to get at it, despite
the fact that it should be the same exact syntax object.

My guess as to what’s going on here is that the issue is not with
make-rename-transformer but with quote-syntax. The above program
expands into a macro definition that has (quote-syntax x) in it,
and the x has a preserved syntax property on it. However, that
property is not actually preserved, despite being marked as preserved.
This is different from other uses of preserved syntax properties
that attach their syntax properties to expressions in the resulting
program, rather than quoted pieces of syntax.

This feels very confusing, and it certainly feels like a bug, but
maybe Matthew has an explanation for this behavior that I don’t
currently understand?

Alexis

-- 
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