Here's what I do: #lang racket/base (require (for-syntax racket/base) syntax/location syntax/srcloc) (define-syntax (mega-quote-syntax stx) (syntax-case stx () [(_ arg) (syntax/loc stx (datum->syntax #f 'arg (build-source-location-list (quote-srcloc arg))))])) (provide mega-quote-syntax)
On Sun, Mar 8, 2015 at 11:45 PM, Alexander D. Knauth <alexan...@knauth.org> wrote: > 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 <ro...@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.dob...@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 <ro...@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 >>>> <alexan...@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 >>> >>> > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -- Jay McCarthy http://jeapostrophe.github.io "Wherefore, be not weary in well-doing, for ye are laying the foundation of a great work. And out of small things proceedeth that which is great." - D&C 64:33 ____________________ Racket Users list: http://lists.racket-lang.org/users