This behavior is intentional, though it could perhaps be more clearly documented. The behavior is hinted at in the documentation for syntax/loc:
> Like syntax, except that the immediate resulting syntax object takes > its source-location information from the result of stx-expr (which > must produce a syntax object), unless the template is just a pattern > variable, or both the source and position of stx-expr are #f. Note the “unless the template is just a pattern variable” condition. The idea is that syntax/loc and quasisyntax/loc only ever adjust the source location information on fresh syntax introduced in the template, never on syntax from external pattern variables or syntax objects inserted with unsyntax. For this reason, (quasisyntax/loc stx #,x) is always equivalent to x. If you do actually want to modify the source location information on a syntax object, you can do it with syntax-e and datum->syntax: (define (replace-outer-srcloc src-stx stx) (datum->syntax stx (syntax-e stx) src-stx stx)) Then you could write (replace-outer-srcloc here y) to get the behavior you want. Alexis > On May 8, 2018, at 09:56, Luke Whittlesey <luke.whittle...@gmail.com> > wrote: > > I'm having trouble understanding quasisyntax/loc in some cases. > > If I have the following example code: > > ```` > #lang racket > > (define here #'here) > (define stx0 (syntax/loc here #'Y)) > (define y #'Y) > (define stx1 (quasisyntax/loc here #,y)) > > (displayln (format "here : line ~a" (syntax-line here))) > (displayln (format "stx0 : line ~a" (syntax-line stx0))) > (displayln (format "stx1 : line ~a" (syntax-line stx1))) > ```` > > It prints : > ```` > here : line 3 > stx0 : line 3 > stx1 : line 5 > ```` > > I expect stx1 to also be at line 3 where `here` is defined. Is this > example an incorrect use of quasisyntax/loc? What am I missing? > > Thanks, > Luke -- 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.