1
0
mirror of https://github.com/janet-lang/janet synced 2025-01-26 07:06:51 +00:00

Return dbg values to work inside complex exprs

This commit is contained in:
LouisJackman 2020-05-16 15:42:16 +01:00
parent fabb722c8d
commit 59302d4f42
No known key found for this signature in database
GPG Key ID: C83A456999EEBC34

View File

@ -950,16 +950,23 @@
and the value for variables. Designed for quick debugging of values and and the value for variables. Designed for quick debugging of values and
nothing else." nothing else."
[& forms] [& forms]
(with-syms [results var]
~(do ~(do
,;(map (fn [arg] (def ,results @[])
(def preface (if (symbol? arg) ,;(map (fn [form]
(string "`" arg "` has value ") (def preface (if (symbol? form)
(string "`" form "` has value ")
"Literal has value ")) "Literal has value "))
~(do ~(do
(prin ,preface) (prin ,preface)
(pp ,arg) (def ,var ,form)
nil)) (pp ,var)
forms))) (array/push ,results ,var)))
forms)
(case (length ,results)
0 nil
1 (,results 0)
,results))))
(defmacro -> (defmacro ->
"Threading macro. Inserts x as the second value in the first form "Threading macro. Inserts x as the second value in the first form