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

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sun Mar 8 23:15:05 EDT 2015

I can't recall the name anymore, but there is a library somewhere to
help with this too.

Robby

On Sun, Mar 8, 2015 at 10:06 PM, Eric Dobson <eric.n.dobson at gmail.com> wrote:
> For an example match does this:
> https://github.com/plt/racket/blob/master/racket/collects/racket/match/gen-match.rkt#L36
>
> Added in this commit
> https://github.com/plt/racket/commit/fc8ed9772a701062dff2b928fb99d90e01b7f177
>
>
> On Sun, Mar 8, 2015 at 2:01 PM, Robby Findler <robby at eecs.northwestern.edu>
> wrote:
>>
>> 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
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>
>

Posted on the users mailing list.