News for hackers. Stuff that matters.
Re:Block Comments Are a Bad Idea by chhs on Wednesday October 11, 2017 @08:05AM (#15449028)
The D Programming language has a neat trick to block commenting out code for debugging purposes. Wrapping code in a version(none) {} block will exclude the block from compilation. The code inside the block must still be syntactically valid so it avoids the problem mentioned in the linked post.

The D Programming Language - Conditional Compilation: https://dlang.org/spec/version.html

Re:Block Comments Are a Bad Idea by TeMPOraL on Wednesday October 11, 2017 @08:14AM (#15449093)
Ditto for Common Lisp, where conditional compilation (with #+ and #- reader macros) is widely used to comment out s-expressions.

EDIT: I only now noticed it was mentioned in the article. I'll therefore add that the example from the article, of using #+nil, is actually not recommended, because it's technically possible that somebody adds a feature flag called "nil". Therefore, it's preferred to use #+(or) or #-(and) for comments (they're degenerate forms of conditional compilation expressions like #+(or flag1 flag2 flag3)).

Re:Block Comments Are a Bad Idea by aardvark179 on Wednesday October 11, 2017 @09:03AM (#15449387)
It's commonly done in C with a #if 0 / #endif preprocessor macro.
Re:Block Comments Are a Bad Idea by msoucy on Wednesday October 11, 2017 @08:43AM (#15449260)
D also supports nesting block comments with /+ +/, which helps when you have example code in your documentation
Re:Block Comments Are a Bad Idea by LeifCarrotson on Wednesday October 11, 2017 @08:58AM (#15449355)
In what ways is that better than "if(false) { }"?
Re:Block Comments Are a Bad Idea by wruza on Wednesday October 11, 2017 @12:21PM (#15450910)
From linked examples it is clear that version() is allowed outside of functions. Since version() already serves a feature, there is no need to overload the meaning of if().