I would really REALLY like to have #ifdef in this Go code I’m working on - there’s this fairly heavyweight debugging stuff that I regularly switch in to chase a particular class of problems, but don’t want active in production code. #ifdef would have exactly the right semantics. Yeah, I know about tags.
Conversation
Notices
-
Embed this notice
Tim Bray (timbray@cosocial.ca)'s status on Wednesday, 13-Dec-2023 12:59:14 JST Tim Bray
-
Embed this notice
Tim Bray (timbray@cosocial.ca)'s status on Wednesday, 13-Dec-2023 12:59:08 JST Tim Bray
@robpike @whenning Tl;dr: I build state machines and debugging them is hard, so I have code that attaches labels to the states, insanely helpful in figuring out where I goofed. In production there can be huge numbers of states, don't want to incur the memory cost. Am seriously considering attaching a structured comment to this code and having a homegrown preprocessor to switch it in/out.
-
Embed this notice
Rob Pike (robpike@hachyderm.io)'s status on Wednesday, 13-Dec-2023 12:59:08 JST Rob Pike
@timbray @whenning I was going to suggest you use m4, but it sounds like you already have a plan.
I understand the value of #ifdefs but lexically directed conditional compilation causes just far too much trouble. The potential for abuse is too high. It's simply not a good idea to have them generally available. Build a custom one for your problem and we'll all be happier.
Haelwenn /элвэн/ :triskell: likes this. -
Embed this notice
Rob Pike (robpike@hachyderm.io)'s status on Wednesday, 13-Dec-2023 12:59:10 JST Rob Pike
-
Embed this notice
whenning (whenning@mastodon.social)'s status on Wednesday, 13-Dec-2023 12:59:13 JST whenning
@timbray maybe 10 years from now the Go team will have a change of heart after saying "YAGNI" to everyone who complains the way they did with generics.
-
Embed this notice
whenning (whenning@mastodon.social)'s status on Wednesday, 13-Dec-2023 12:59:50 JST whenning
@robpike @timbray As I see it, your choice of words in saying things like "too much trouble" and "potential for abuse" and the assumptions implicit in those statements are what this and the decision to have support for any feature in a language boils down to.
-
Embed this notice
Rob Pike (robpike@hachyderm.io)'s status on Wednesday, 13-Dec-2023 12:59:50 JST Rob Pike
@whenning @timbray That and decades of experience debugging important things that break in the real world.
Haelwenn /элвэн/ :triskell: likes this.
-
Embed this notice