From: Edward Elliott on 19 Apr 2006 02:15 Atanas Banov wrote: > want to comment block of code? use tripple-quotes. does not nest? ahhh, > maybe it's time to get rid of that block you commented out a month ago > "just in case the new code doesnt work". > > that gives you incentive to tidy up. don't be a code slob... don't > leave a mess forever ;-) And when the section I want to comment out contains a legit doc string in the middle, triple-quotes won't work. There are valid reasons to nest comments which have nothing to do with laziness or sloppy code. Forcing programmers to write clean code with syntax is like teaching a pig to sing: it wastes your time and annoys the pig. Good coding is a state of mind, not a parser option.
From: Edward Elliott on 19 Apr 2006 02:24 Ben Finney wrote: > And/or switch to an editor that can perform editing operations on a > range of lines. I'm not unsympathetic to this point of view, as I would feel hamstrung without my vim. It's more that I object to the paternalism of telling people they have to use such an editor. There are times when notepad is all that's available. On top of that, the expressive power of nested comments seems greater than an endless string of ^#s. Sometimes it's just easier to see what's going on.
From: Edward Elliott on 19 Apr 2006 02:34 Ben Finney wrote: > Indeed. Using revision control means never needing to comment out > blocks of code. Typing (* and *) on a few line will always be quicker, easier, and less confusing than any rcs diffs/restores. Once you delete the code you can no longer see it or add pieces back in without retrieving it from an external store. I'm not saying nested comments solve every problem, just that there exists a certain (perhaps small) class of problems they solve particularly well. Personally, I rarely leave code commented out beyond a single coding session. But my particular coding habits aren't relevant here.
From: Lawrence D'Oliveiro on 19 Apr 2006 03:12 In article <wZe1g.72406$dW3.16444(a)newssvr21.news.prodigy.com>, Edward Elliott <nobody(a)127.0.0.1> wrote: >ML has a >very elegant system for nested comments with (* and *). Which, if you mistype an opening or closing comment symbol, can lead to some very mysterious syntax errors.
From: Duncan Booth on 19 Apr 2006 03:45
Edward Elliott wrote: > Ben Finney wrote: >> Indeed. Using revision control means never needing to comment out >> blocks of code. > > Typing (* and *) on a few line will always be quicker, easier, and > less confusing than any rcs diffs/restores. Once you delete the code > you can no longer see it or add pieces back in without retrieving it > from an external store. I'm not saying nested comments solve every > problem, just that there exists a certain (perhaps small) class of > problems they solve particularly well. Would you care to name a few languages which support nested block comments? There really aren't many: ML as you mentioned; Standard Pascal doesn't permit nesting of comments but *some* implementations do allow it. Want to comment out a block of code in C++? The only (nearly) reliable way is to insert single-line comments down the block. You can't use a block comment if there are any other block comments inside the code you want to block out. The danger of block comments is that if you forget to close the comment you can accidentally comment out a large part of your code. With support from the editor (coloured highlighting of comments) this isn't so bad, but then if you have a decent editor you don't need the block comments anyway as you will be able to comment/uncomment a block in your editor. Doc strings will usually work as an alternative, especially since you have a choice of two flavours of triple quoted strings, so if you use one for docstrings the other is always free for your temporary block comments. > Forcing programmers to write clean code with syntax is like teaching a > pig to sing: it wastes your time and annoys the pig. This pig gets much more annoyed having to maintain code which has large chunks of unneeded commented out code left over from some other programmer, or which has completely messed up indentation. |