mirror of
https://github.com/janet-lang/janet
synced 2025-04-26 20:53:12 +00:00
Incorporate suggestions from PR
This commit is contained in:
parent
ca3dac7e87
commit
9109e369ff
@ -945,24 +945,27 @@
|
|||||||
(array/push parts (tuple apply f $args)))
|
(array/push parts (tuple apply f $args)))
|
||||||
(tuple 'fn (tuple '& $args) (tuple/slice parts 0)))
|
(tuple 'fn (tuple '& $args) (tuple/slice parts 0)))
|
||||||
|
|
||||||
(defmacro dbg
|
(defmacro trace-pp
|
||||||
"Displays the variables or literals listed, providing both the name and
|
"Displays the variables or literals listed, providing both the name and
|
||||||
and the value for variables. Designed for quick debugging of values and
|
and the value for variables. Designed for quick debugging of values. Returns
|
||||||
nothing else."
|
the traced forms: nil for none, the form itself for one, and a tuple of the
|
||||||
|
forms for many."
|
||||||
[& forms]
|
[& forms]
|
||||||
(with-syms [results var]
|
(with-syms [results var]
|
||||||
~(do
|
~(do
|
||||||
(def ,results @[])
|
(def ,results @[])
|
||||||
,;(map (fn [form]
|
,;(map (fn [form]
|
||||||
(def preface (if (symbol? form)
|
(def preface (if (symbol? form)
|
||||||
(string "`" form "` has value ")
|
(string form " is")
|
||||||
"Literal has value "))
|
"is"))
|
||||||
~(do
|
~(do
|
||||||
(prin ,preface)
|
(def ,var ,form)
|
||||||
(def ,var ,form)
|
(eprintf (string "%s " (dyn :pretty-format "%q"))
|
||||||
(pp ,var)
|
,preface
|
||||||
(array/push ,results ,var)))
|
,var)
|
||||||
forms)
|
(eflush)
|
||||||
|
(array/push ,results ,var)))
|
||||||
|
forms)
|
||||||
(case (length ,results)
|
(case (length ,results)
|
||||||
0 nil
|
0 nil
|
||||||
1 (,results 0)
|
1 (,results 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user