This is my personal preference, but from experience I prefer languages that don't shun concepts because they're bad programming practice. I can understand if something is difficult to implement or prevents other features from being added, but if a feature is possible, I say add it---it might come in handy sometimes. There's a reason languages like C, C++, Ruby, and Javascript are immensely popular. It's because progr…
See also GOTO which is a wart 99.9% of the time but really useful for writing e.g. parsers.
Block Comments Are a Bad Idea
11–20 of 84 posts
Re: Block Comments Are a Bad Idea
#12Surely the solution is heredocs? You effectively define your own comment closing string at the comment opening point.
Re: Block Comments Are a Bad Idea
#13Re: Block Comments Are a Bad Idea
#14We're dealing with text. A program can be expressed in text, actually every piece of information can be converted to text some way or another. The question is if it's the right way to do it. It's not.
I know why we chose text at the time. It doesn't make sense today.
In this case, we should be using a tool that would let us write comments without worrying about delimiters or escaped characters. That's so 20th century.
Re: Block Comments Are a Bad Idea
#15Additionally..
> This is perfectly cromulent Haskell.
I'm still impressed whenever someone can correctly use this word to embiggen the subject under discussion.
Re: Block Comments Are a Bad Idea
#16Commenting out whole sections of code incredibly useful for debugging and rapid prototyping.
Many editors allow you to select the section and line-comment it as a whole.
Re: Block Comments Are a Bad Idea
#17Earlier quoted context omitted.
See also GOTO which is a wart 99.9% of the time but really useful for writing e.g. parsers.
Error handling.
True, in a language like C these don't apply necessarily and goto still has some use -
Re: Block Comments Are a Bad Idea
#18I've never had an issue with a block comment that couldn't be fixed in a couple seconds. The usefulness and readability of a well formatted block comment, especially for documentation generation, far outweighs any inconveniences in fixing a broken implementation.
Re: Block Comments Are a Bad Idea
#19The 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
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
#20 [:div
[:p "hello world"]
#_ [:pre "this debug block is commented out"]]