Marc, is there any way I can get the sourcecode filename, name of global define, and line number, that a particular line was compiled at?
E.g. (so here, ##file, ##in-define and ##line would be output by the macro so the compiler would actually compile those at line 3, 6 and 8.)
(define-macro (loc) `(print "This was printed at " ##file " in define " ##in-define " line " ##line "\n"))
(loc)
(define (something)
(loc))
(loc)
?
Thanks.
Afficher les réponses par date
You need ##define-syntax for that…
(##define-syntax loc (lambda (src) (let ((loc (call-with-output-string "location: " (lambda (port) (##display-locat (##source-locat src) #t port))))) (println loc) #f)))
Note that you get the filename, line and column numbers, but you don’t have access to the name of the global function that contains the macro call (this is only known after the macro expansion pass).
Marc
On Jun 24, 2016, at 4:55 AM, Adam adam.mlmb@gmail.com wrote:
Marc, is there any way I can get the sourcecode filename, name of global define, and line number, that a particular line was compiled at?
E.g. (so here, ##file, ##in-define and ##line would be output by the macro so the compiler would actually compile those at line 3, 6 and 8.)
(define-macro (loc) `(print "This was printed at " ##file " in define " ##in-define " line " ##line "\n"))
(loc)
(define (something) (loc))
(loc)
?
Thanks.