mirror of
https://github.com/janet-lang/janet
synced 2025-01-13 00:50:26 +00:00
Add a dbg macro for easy var dumping
This commit is contained in:
parent
48d31ad7bc
commit
fabb722c8d
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user