dbg macro
Dev tools
debugging macro
SHOW HN2019
How HN took it
7 positive, 17 neutral or asking, 0 mixed, 1 critical, out of 25 comments about the project. Thread score +0.21.
Idea: 5 for, 0 againstDesign: 1 for, 1 against
The thread, comment by comment
Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.
positive neutral or mixed critical about another commenter or something else the maker
What HN said
What people liked
Convenient for debugging when a debugger is impractical
From 2 comments
This seems very much inspired by the `dbg` macro recently introduced in Rust. [1] Which in turn was inspired by Haskell s `Debug.Trace` functions [2]. It's definitely a…
the_duke on HNOh ... this is really neat. I like how you can wrap an subexpression or prettyprint vectors. When the debugger is too cumbersome to use good old prints is always a nice fallback.
rightbyte on HN
Objections
Always enabled, no runtime enable/disable; performance concerns
From 2 comments
Would be nice to offer runtime enable/disable. Out of curiosity, I wrote a little benchmark and submitted as a PR: https://github.com/sharkdp/dbg-macro/pull/57 The key idea is…
asah on HNThis is not a real disabling of dbg. dbg.h should support a function that disables writing out to the screen, but still returning the expression during run-time. You could try it…
xiphias2 on HN
Feels like a ricer feature; logging libraries would be better
From 1 comment
This feels like too much of a "ricer" feature, at least the way it's implemented. Instead, you want: * A pretty-printer library (possibly single-header) * A function for…
einpoklum on HN
Requests
Runtime enable/disable
From 1 comment
Would be nice to offer runtime enable/disable. Out of curiosity, I wrote a little benchmark and submitted as a PR: https://github.com/sharkdp/dbg-macro/pull/57 The key idea is…
asah on HN
Integration with logging libraries
From 1 comment
An alternative route might be to find a way to integrate this code with a logging library like spdlog. This way you'd get the cool short notation of dbg(...) and the ability to…
pnako on HN
Questions
Does dbg evaluate its argument twice?
From 1 comment
Nice idea! I would appreciate a warning from the author specifying whether dbg evaluates its argument twice, as if so one must be careful with side effects when using it.
WhiteSage on HN
Alternatives named
Rust dbg! macro
From 1 comment
This seems very much inspired by the `dbg` macro recently introduced in Rust. [1] Which in turn was inspired by Haskell s `Debug.Trace` functions [2]. It's definitely a…
the_duke on HN
Python f-string self-documenting expressions
From 1 comment
Python 3.8 has similar feature for f-strings : https://bugs.python.org/issue36817 print(f"{name=}") expands to print(f"name={name}")
xtreak29 on HN
glog DLOG and Qt qDebug
From 2 comments
This is neat. The obvious comparison is glog's DLOG feature.
bt848 on HNIt also reminds me of Qt's qDebug macros
empyrical on HN
Mozilla DbgMacro.h
From 1 comment
Mozilla has something similar in Gecko's codebase, inspired by the Rust macro: https://searchfox.org/mozilla-central/source/mfbt/DbgMacro.h
fabrice_d on HN