[{"data":1,"prerenderedAt":336},["ShallowReactive",2],{"project-21034615":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":27,"sentiment":28,"stance_mix":29,"scored_comments":34,"aspects":35,"strip":41,"post_text":43,"what":44,"said":64,"maker_in_thread":147,"shape":156,"grid":160,"attempts":300,"same_week":301,"maker_shows":272,"maker_hidden":328,"reader_version":329,"card":330},"21034615","dbg macro","A dbg(...) macro for C++","title","Show HN: A dbg(...) macro for C++","https:\u002F\u002Fgithub.com\u002Fsharkdp\u002Fdbg-macro","github.com","sharkdp",1569064196,2019,162,51,251,2195,12,"notable","dev_tools","debugging macro","library",[24,5,25,26],"c++ debugging","print debugging","rust dbg","loved",0.206,{"positive":30,"neutral":31,"mixed":32,"critical":33},7,17,0,1,25,{"idea":36,"performance":38,"design":39,"execution":40},{"positive":37,"critical":32},5,{"positive":32,"critical":32},{"positive":33,"critical":33},{"positive":32,"critical":32},[37,32,32,32,32,32,42,32,32,32,32,32,32,32,32,32,32,42,42,42,42,42,32,42,32,42,37,32,42,42,32,37,37,37,37,42,42,33,32,37],3,null,{"problem":43,"audience":45,"pricing":43,"motivation":52,"time_to_build":43,"stack":57,"openness":62,"stage":63,"team_size":63},{"value":46,"source":47,"evidence":48},"C++ developers","inferred",[49],{"id":50,"by":11,"text":51},"21035080","Yes, it is definitely inspired by Rusts `dbg!(..)` macro (see bottom part of the README). A lot of my open source projects are written in Rust and I really liked the idea of the…",{"value":53,"source":54,"evidence":55},"Wanted something like Rust's dbg! macro for their C++ work","maker",[56],{"id":50,"by":11,"text":51},[58],{"value":59,"source":47,"evidence":60},"C++",[61],{"id":50,"by":11,"text":51},"open_source","unknown",{"praise":65,"objections":78,"requests":97,"questions":109,"alternatives":117},[66],{"value":67,"source":68,"evidence":69},"Convenient for debugging when a debugger is impractical","commenter",[70,74],{"id":71,"by":72,"text":73},"21034954","the_duke","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…",{"id":75,"by":76,"text":77},"21035617","rightbyte","Oh ... 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.",[79,90],{"value":80,"source":68,"evidence":81},"Always enabled, no runtime enable\u002Fdisable; performance concerns",[82,86],{"id":83,"by":84,"text":85},"21035243","asah","Would be nice to offer runtime enable\u002Fdisable. Out of curiosity, I wrote a little benchmark and submitted as a PR: https:\u002F\u002Fgithub.com\u002Fsharkdp\u002Fdbg-macro\u002Fpull\u002F57 The key idea is…",{"id":87,"by":88,"text":89},"21035467","xiphias2","This 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…",{"value":91,"source":68,"evidence":92},"Feels like a ricer feature; logging libraries would be better",[93],{"id":94,"by":95,"text":96},"21035874","einpoklum","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…",[98,102],{"value":99,"source":68,"evidence":100},"Runtime enable\u002Fdisable",[101],{"id":83,"by":84,"text":85},{"value":103,"source":68,"evidence":104},"Integration with logging libraries",[105],{"id":106,"by":107,"text":108},"21035712","pnako","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…",[110],{"value":111,"source":68,"evidence":112},"Does dbg evaluate its argument twice?",[113],{"id":114,"by":115,"text":116},"21036083","WhiteSage","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.",[118,122,129,140],{"value":119,"source":68,"evidence":120},"Rust dbg! macro",[121],{"id":71,"by":72,"text":73},{"value":123,"source":68,"evidence":124},"Python f-string self-documenting expressions",[125],{"id":126,"by":127,"text":128},"21035070","xtreak29","Python 3.8 has similar feature for f-strings : https:\u002F\u002Fbugs.python.org\u002Fissue36817 print(f\"{name=}\") expands to print(f\"name={name}\")",{"value":130,"source":68,"evidence":131},"glog DLOG and Qt qDebug",[132,136],{"id":133,"by":134,"text":135},"21037663","bt848","This is neat. The obvious comparison is glog's DLOG feature.",{"id":137,"by":138,"text":139},"21038380","empyrical","It also reminds me of Qt's qDebug macros",{"value":141,"source":68,"evidence":142},"Mozilla DbgMacro.h",[143],{"id":144,"by":145,"text":146},"21038936","fabrice_d","Mozilla has something similar in Gecko's codebase, inspired by the Rust macro: https:\u002F\u002Fsearchfox.org\u002Fmozilla-central\u002Fsource\u002Fmfbt\u002FDbgMacro.h",{"comments":42,"answered":32,"key":148},[149,150,153],{"id":50,"text":51},{"id":151,"text":152},"21035902","Thank you for the feedback. We deliberately chose not to do this (see discussion in https:\u002F\u002Fgithub.com\u002Fsharkdp\u002Fdbg-macro\u002Fissues\u002F26), mainly for the reasons given in the Rust…",{"id":154,"text":155},"21036092","Thank you for the feedback. No, it does not evaluate its argument twice - see this test:…",{"commenters":157,"max_depth":37,"maker_replies":42,"first_comment_mins":158,"lifespan_hours":159},39,79,148,[161,163,167,170,172,174,176,178,182,185,188,190,192,195,198,200,203,206,209,212,214,217,219,220,223,224,227,231,232,235,239,241,242,243,245,248,252,255,258,260,263,267,270,274,277,281,284,287,290,293,296],[71,32,37,162,72,32],"project\u002Fpositive\u002Fidea",[164,32,32,165,166,32],"21034986","commenter\u002Fneutral\u002Fnone","KenanSulayman",[168,32,32,165,169,32],"21035067","masklinn",[171,32,32,165,72,32],"21035111",[173,32,32,165,169,32],"21035285",[175,32,32,165,72,32],"21035747",[126,32,32,177,127,32],"other\u002Fneutral\u002Fidea",[179,32,42,180,181,32],"21035120","project\u002Fneutral\u002Fidea","chrismorgan",[183,32,32,184,127,32],"21035595","other\u002Fneutral\u002Fnone",[186,32,32,165,187,32],"21037235","giancarlostoro",[50,32,32,189,11,33],"maker\u002Fneutral\u002Fidea",[191,32,32,165,72,32],"21035123",[193,32,32,184,194,32],"21035333","solinent",[196,32,32,165,197,32],"21035400","pcr910303",[199,32,32,165,194,32],"21037498",[201,32,32,165,202,32],"21035560","saagarjha",[204,32,32,165,205,32],"21038855","unphased",[207,32,32,184,208,32],"21035817","apaprocki",[210,32,32,184,211,32],"21035929","jcelerier",[213,32,32,165,194,32],"21037424",[215,32,32,184,216,32],"21036284","furyofantares",[83,33,42,218,84,32],"project\u002Fneutral\u002Fperformance",[87,33,42,218,88,32],[221,33,42,222,84,32],"21035601","project\u002Fneutral\u002Fdesign",[106,33,42,180,107,32],[225,33,42,218,226,32],"21036086","jnordwick",[228,229,32,165,230,32],"21071367",2,"s_gourichon",[144,42,42,180,145,32],[233,42,32,184,234,32],"21039020","jedimastert",[236,237,42,180,238,32],"21035811",4,"hellofunk",[151,237,32,240,11,33],"maker\u002Fneutral\u002Fdesign",[133,37,42,180,134,32],[137,37,42,180,138,32],[75,244,37,162,76,32],6,[246,30,32,184,247,32],"21036038","DFHippie",[249,250,42,180,251,32],"21039057",8,"rat87",[253,254,42,222,107,32],"21034924",9,[114,256,42,257,115,32],10,"project\u002Fneutral\u002Fexecution",[154,256,32,259,11,33],"maker\u002Fpositive\u002Fexecution",[261,256,37,262,115,32],"21040125","maker\u002Fpositive\u002Fnone",[264,265,37,162,266,32],"21036218",11,"maurodelazeri",[268,18,42,180,269,32],"21039403","halfer53",[271,272,37,162,273,32],"21037048",13,"israrkhan",[275,272,37,162,276,32],"21040932","eerimoq",[278,279,42,180,280,32],"21036230",14,"97b683f8",[282,279,42,222,283,32],"21036346","Ives",[285,279,42,180,286,32],"21042802","kazinator",[94,288,33,289,95,32],15,"project\u002Fcritical\u002Fdesign",[291,288,32,165,292,32],"21037343","stjohnswarts",[294,288,32,184,295,32],"21039935","quickthrower2",[297,288,37,298,299,32],"21093039","project\u002Fpositive\u002Fdesign","Rietty",[],[302,307,312,316,320,324],{"id":303,"name":304,"points":305,"category":306},"21037167","james.darpinian.com",863,"productivity",{"id":308,"name":309,"points":310,"category":311},"21042468","Guard",502,"security_privacy",{"id":313,"name":314,"points":315,"category":20},"21070934","HTTP Mock",341,{"id":317,"name":318,"points":319,"category":306},"21035621","Shiori v1.5",286,{"id":321,"name":322,"points":323,"category":306},"21035330","Best of Show HN",249,{"id":325,"name":326,"points":327,"category":306},"21050636","Instant, Self-Destructing Websites",242,false,"v2",{"id":331,"name":5,"line":6,"ai":328,"cat":20,"year":13,"points":14,"comments":15,"rec":27,"s":332,"top":18,"kw":333,"maker":11,"domain":10,"tier":19,"attempts":32,"strip":334,"url":9,"mix":335,"praise":67,"objection":80,"sub":21},21034615,0.21,[24,5,25,26],"5000003000000000033333030350330555533105",[30,31,32,33],1794036581122]