Alex, yes thank you, the quote-srcloc works at run time, so for example:

  (define-syntax (here3 stx) 
      (let(
             [program `(quote-srcloc ,stx)]
            )

        (datum->syntax stx program)
        ))

Will print the call point.  What the heck is this macro, as it is being passed 
the same argument, stx, in both cases (syntax time and run time).

Yep! build-source-location works here.

  (define-syntax (here2 stx) 
      (let(
            [a-location (build-source-location stx)]
            )
        (datum->syntax stx a-location)
        ))

I hadn't thought to try it because firstly I had expected to find a location 
accessor function in the syntax object definition,  but also because in section 
9.1 of the reference manual none of the many examples given show syntax 
objects.  And the manual made it sound like it makes syntax objects, but said 
nothing it accepting them:

   These procedures combine multiple (zero or more) source 
   locations, merging locations within the same source and 
   reporting #f for locations that span sources. They also 
   convert the result to the desired representation: srcloc, 
   list, vector, or syntax object, respectively.

Greg, syntax/loc is beautiful (so far ;-) it goes beyond my hopes, seems it 
shoudl be prominent in the docs.

  (define-syntax (messup4 stx) 
    (syntax/loc stx
      (let (
             [a 7]
             [b 9]
             )
        (^ a b)
       )))
        
  (messup4)

  rac...@test-here.rkt> (enter! "test-macro-dev-error.rkt")
  test-macro-dev-error.rkt:62:35: ^: unbound identifier in module
    in: ^
    errortrace...:
    context...:
     /usr/share/racket/pkgs/errortrace-lib/errortrace/errortrace-


The error message points directly at the caret in the quoted string. (who knows 
maybe our programmer thought that meant xor?)

However I don't get the 'immediate'.  It did not stop at the let, but descended 
to the caret.  In your blog post example it descended to the divide - but did 
not descend through the begin ??? Is this a varation of the function traceback 
not showing tail called functions?  I.e. something related to optimization?  
When does it descend, and when doesn't it?

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

Reply via email to