mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
feat: add Dynamic.Debug.trace (#1279)
This commit is contained in:
parent
74d64a85bb
commit
f3944ce73d
@ -73,6 +73,22 @@ integers [`imod`](#imod).")
|
|||||||
(defndynamic tail [s]
|
(defndynamic tail [s]
|
||||||
(String.suffix s 1))
|
(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))
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user