3 ms·
As the article mentions, unlike D [0], C++ block comments can't be nested, which is a point in favour of the #if 0 trick. I agree it's generally better to use
by MaxBarraclough 6y ago
As the article mentions, unlike D [0], C++ block comments can't be nested, which is a point in favour of the #if 0 trick.
I agree it's generally better to use line comments using a good editor. This has the advantage that it plays nice with git diff, which will faithfully show every affected line. If you use block comments or #if 0, it will only show the 2 new lines that start and end the new comment block.
Trivia: Opposite to C, which originally had block comments and not line comments, the Ada language only supports line comments, with the reasoning that it's clearer at a glance whether a line has been commented out (especially in the absence of syntax highlighting).
[0] https://wiki.dlang.org/Commenting_out_code#Nested_comments https://wiki.dlang.org/Commenting_out_code#Nested_comments
- hctaw 6y agoI know the reason why its done, and again, this is not a problem if you know how to use your editor. The real anti-pattern is commenting out code to remove it. Delete it if not necessary, line comment anything else.