1
0
mirror of https://github.com/janet-lang/janet synced 2025-09-07 13:28:03 +00:00

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

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