The identifiers are the same, but only when comparing their phase-1 bindings. When doing traversal of syntax objects, you need to keep track of the phase that identifiers are meaningful at.
Here's a version of your paste comparing at the right phase: http://pasterack.org/pastes/95574 Here's some quite complex code that walks fully-expanded syntax, and (I think) handles phases right as of yesterday: https://github.com/samth/pycket/blob/master/pycket/pycket-lang/expand.rkt . See the `current-phase` parameter. Sam On Wed, Dec 16, 2015 at 6:22 PM Leif Andersen <l...@leifandersen.net> wrote: > Hello, > > I am finding that when I have a syntax object: > > #'(begin-for-syntax (define-values (x) 5), when I expand it it becomes: > #'(begin-for-syntax (define-values (x) '5). However, the quote in that > expansion will not be free-identifier=? to the one if I were to type > it out by hand: > #'(begin-for-syntax (define-values (x) '5), and expand that. > > If however, I have a `begin` rather than a `begin-for-syntax`, giving me: > #'(begin (define-values (x) 5) it works as expected. (The quote it > expands into is free-identifier=? to the one that I am using.) > > I am calling expand (or expand-syntax) directly, and not really using > any phase levels outside of whatever `expand` may use. > > Here is my code: http://pasterack.org/pastes/78711 > > #lang racket > > (define x (expand #'(begin-for-syntax > (define-values (x) '5)))) > (define y (expand #'(begin-for-syntax > (define-values (x) 5)))) > > (define (ident=? stx) > (syntax-case stx () > [(_ (_ (_) (var _))) > (free-identifier=? #'var #'quote)])) > > (syntax->datum x) > (syntax->datum y) > (ident=? x) > (ident=? y) > > Is this expected behavior? If so, can you give me some intuition as to why? > > Thank you. > > ~Leif Andersen > > -- > 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. > -- 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.