feat: add Dynamic.Debug.trace (#1279)

This commit is contained in:
Veit Heller 2021-07-14 08:14:07 +02:00 committed by GitHub
parent 74d64a85bb
commit f3944ce73d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,6 +73,22 @@ integers [`imod`](#imod).")
(defndynamic tail [s]
(String.suffix s 1))
)
(defmodule Debug
(doc trace "prints the value of an expression to `stdout`, then returns its value.")
(defmacro trace [x]
(let [sym (gensym)]
`(let-do [%sym %x]
; we use eval here to ensure we resolve the symbol before putting it
; into file, line, and column
(macro-log
%(eval `(file %x)) ":"
%(eval `(line %x)) ":"
%(eval `(column %x)) ": "
%sym)
%sym))
)
)
)