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

From: Alexander D. Knauth (alexander at knauth.org)
Date: Sun Mar 8 23:45:18 EDT 2015

Do you mean syntax/location ?

But that wouldn’t work for what I was doing.  What I ended up doing was defining a macro that defines another macro and calls the new macro with the syntax-objects, and puts the code that checks the source locations in the definition of the new macro.  


On Mar 8, 2015, at 11:15 PM, Robby Findler <robby at eecs.northwestern.edu> wrote:

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