News for hackers. Stuff that matters.
Re:Block Comments Are a Bad Idea by iiv on Wednesday October 11, 2017 @07:51AM (#15448970)
How would one do inline comments without block comments?

I don't know if Python's triple-quote can be used inline, but otherwise that seems like a good solution. I am not entirely familiar with Python comments, does any of his arguments apply to triple-quotes?

Re:Block Comments Are a Bad Idea by simias on Wednesday October 11, 2017 @08:15AM (#15449097)
You mean comments in the middle of a line of code? I don't think I've ever done that (and I write a lot of C which would allow it). Seems like a readability nightmare to me, even with proper syntax highlighting.

I guess it could be useful if you want to temporarily debug the middle of a line for debugging purposes but in this case you could just add a line break if blockquote didn't exist.

That being said I don't feel very strongly about this topic, I let emacs handle the commenting for me so I never really have issues with nested comments. Besides commenting comments is probably only useful for temporary debugging.

I do feel strongly about people committing commented/dead code however, it's just distracting and misleading. Nowadays versioning your code is just one `git init` away so nobody should be worried about keeping old dead code "just in case".

Sample code is acceptable however, I like Rust's approach where commented sample code can actually be tested to make sure it's up to date.

Re:Block Comments Are a Bad Idea by beojan on Wednesday October 11, 2017 @07:57AM (#15448989)
Triple-quotes are string literals, not comments. It's just that a string literal at the start of a function, file, or class is a docstring.
Re:Block Comments Are a Bad Idea by chrismorgan on Wednesday October 11, 2017 @08:19AM (#15449120)
I view inline comments as a code smell in most languages; I can’t think off-hand of having seen even one occasion where the code couldn’t be tweaked into another nicer form that didn’t depend on inline comments.
Re:Block Comments Are a Bad Idea by umbrai_nation on Wednesday October 11, 2017 @08:35AM (#15449215)
I use them with functions that have too many arguments. It's not always feasible to fix the problem at the source.

damageDealt = calcDamage(weaponType, monsterType, DamageType.FIRE, null /* specialEffectFlags /, false / hasMagicTargeting */ );

It's definitely a code smell, but it's much better than nothing and I'm always glad to see these comments when I come back to the code.

Re:Block Comments Are a Bad Idea by chrismorgan on Wednesday October 11, 2017 @09:18AM (#15449457)
Yeah, that was the closest I could think of. But in Python you’d use keyword arguments, and in JavaScript you’d use objects with named fields in lieu of that, and in Rust you’d commonly try to use struct fields or custom enums for such things (I still want named arguments there).

The extreme in your case would be `hasMagicTargeting = false` and then pass `hasMagicTargeting` instead of `false`.

Re:Block Comments Are a Bad Idea by ragebol on Wednesday October 11, 2017 @08:33AM (#15449195)
Yes, that is very well possible.

However, I do not recommend using triple-quotes for comments, as git diff only shows 2 lines with quotes while the actual difference is much bigger.