Closed mtruyens closed 4 years ago
You can use dbgn
in your case like this.
(defn qualified-keyword?
"Return true if x is a keyword with a namespace"
[x] (dbgn (and (keyword? x) (namespace x) true)))
(qualified-keyword? :hi/there)
{:ns examples.dbg, :line 140}
dbgn: (and (keyword? x) (namespace x) true) =>
| x =>
| :hi/there
| (keyword? x) =>
| true
| (namespace x) =>
| "hi"
| (and (keyword? x) (namespace x) true) =>
| true
Do you want to print the result using dbg
like this, in the same way as in (dbg (-> ...))
?
(defn qualified-keyword?
"Return true if x is a keyword with a namespace"
[x] (dbg (and (keyword? x) (namespace x) true)))
(qualified-keyword? :hi/there)
{:ns examples.dbg, :line 140}
dbg: (and (keyword? x) (namespace x) true) =>
| (keyword? x) =>
| true
| (namespace x) =>
| "hi"
| (and (keyword? x) (namespace x) true) =>
| true
IIRC, when I tried a similar example yesterday, the results were difficult to use because of deeply nested forms being printed.
But I should then look into it again, you have clearly thought about this possibility in your design. Thanks!
I advise you to use dbg
selectively inside dbgn
like this, if you want to avoid printing a deeply nested structure inside dbgn
.
(dbgn (and (dbg (deeply-nested-form ......)) (another-form ...) ...))
The above dbg
will prevent dbgn
from printing (deeply-nested-form ...)
recursively.
Refer to: https://github.com/philoskim/debux#dbg-inside-dbgn-or-vice-versa
When debugging, I frequently want to know the evaluation of the individual components of a boolean expression. It would be cool if Debux could support and/or as special macros.