Add a dbg macro for easy var dumping

This commit is contained in:
LouisJackman 2020-05-16 15:15:57 +01:00
parent 48d31ad7bc
commit fabb722c8d
No known key found for this signature in database
GPG Key ID: C83A456999EEBC34
1 changed files with 16 additions and 0 deletions

View File

@ -945,6 +945,22 @@
(array/push parts (tuple apply f $args)))
(tuple 'fn (tuple '& $args) (tuple/slice parts 0)))
(defmacro dbg
"Displays the variables or literals listed, providing both the name and
and the value for variables. Designed for quick debugging of values and
nothing else."
[& forms]
~(do
,;(map (fn [arg]
(def preface (if (symbol? arg)
(string "`" arg "` has value ")
"Literal has value "))
~(do
(prin ,preface)
(pp ,arg)
nil))
forms)))
(defmacro ->
"Threading macro. Inserts x as the second value in the first form
in forms, and inserts the modified first form into the second form