[racket] source locations of syntax objects in a required file

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sun Mar 8 17:01:53 EDT 2015

Syntax object constants, when compiled, have their source location
information discarded. So you're running in drracket, I guess, with
automatic compilation on. The usual way around this is to write a
macro that explicitly tracks the source locations that you care about
and use it (instead of using quote-syntax).

Robby


On Sun, Mar 8, 2015 at 1:19 PM, Alexander D. Knauth
<alexander at knauth.org> wrote:
> If I have these files:
> test.rkt:
> #lang racket
> (define stx #'here)
> (syntax-source stx)
> (syntax-line stx)
> (syntax-column stx)
> (syntax-position stx)
> (syntax-span stx)
> require-test.rkt:
> #lang racket
> (require "test.rkt")
>
> Then when I run test.rkt, it prints:
> #<path:/Users/Alex/Documents/DrRacket/srcloc/test.rkt>
> 2
> 14
> 28
> 4
> As expected.  But when I run require-test.rkt, it prints:
> #f
> #f
> #f
> #f
> 0
>
> What happened to the source locations?  Why is it doing this?
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.