D - nested comments?
- Pavel Minayev (1/1) Jan 01 2002 Are nested multiline /* */ comments allowed in D?
- Walter (3/4) Jan 01 2002 no. Use the version statement to block out sections.
- Pavel Minayev (8/9) Jan 01 2002 Unfortunately, version cannot comment out blocks with bad syntax -
- Walter (4/13) Jan 01 2002 I've been considering making version more tolerant of bad syntax, but it...
- Sean L. Palmer (5/20) Jan 02 2002 That's perfect. Surely we can make the brackets nest correctly.
- Pavel Minayev (7/9) Jan 02 2002 is
- Walter (4/13) Jan 02 2002 I'd like to try using the version statement unless it really reaches a d...
- Robert W. Cunningham (7/22) Jan 02 2002 ... And we have to resort to using a pre-processor!
- Pavel Minayev (7/11) Jan 03 2002 for
- OddesE (37/46) Jan 17 2002 Yes indeed, what *is* wrong with nested comments?
- Martin York (5/7) Jan 17 2002 Just use
- Pavel Minayev (5/10) Jan 17 2002 D doesn't have preprocessor!
- Martin York (7/21) Jan 17 2002 Maybe this is a feature that needs to be added to languages (in general)
- Pavel Minayev (8/11) Jan 17 2002 D has this, in form of debug() statement (RTFM!). Comments, however,
- Ben Cohen (8/13) Jan 18 2002 What about a type of comment which can be nested but which forces you to
- Russell Borogove (15/36) Jan 18 2002 Sounds like more complexity to no benefit. It's not hard to
- Pavel Minayev (6/7) Jan 18 2002 Who does? But it happens when I first comment out a 10-line
- Juan Carlos Arevalo Baeza (31/38) Jan 18 2002 On the other side, personally, most of the times I comment something ...
- Pavel Minayev (6/19) Jan 18 2002 out,
- Juan Carlos Arevalo Baeza (11/23) Jan 18 2002 :) I couldn't believe it when I found it...
- Walter (5/19) Jan 20 2002 contents
- Walter (4/5) Jan 20 2002 Then you're covered. Use // for normal commenting, and then /* */ is
- Sean L. Palmer (5/10) Jan 20 2002 You still can't comment out a block that contains other commented-out
- Walter (3/15) Jan 20 2002 True.
- la7y6nvo shamko.com (29/85) Jan 18 2002 I'd like to take the other side of this argument and say
- Pavel Minayev (11/35) Jan 18 2002 D has quite a lot of changes from C. Just to remember syntax used
- OddesE (55/95) Jan 19 2002 In response to the dicussion between la7y6nvo and
-
Roberto Mariottini
(9/30)
Jan 21 2002
"OddesE"
ha scritto nel messaggio - Walter (9/13) Jan 20 2002 I use that too. But I keep getting grief from various compilers that ins...
-
OddesE
(13/18)
Jan 19 2002
- Pavel Minayev (3/8) Jan 19 2002 Why? If it uses /** */, why can't I use /* */ ?
- OddesE (32/41) Jan 20 2002 If you have functions with documentation like this:
- Roberto Mariottini (15/25) Jan 07 2002 I also often need nested comments as a fast way to comment-out weird cod...
- Pavel Minayev (3/6) Jan 07 2002 Maybe then <@ @> ?
- Russell Borogove (7/37) Jan 07 2002 Insert the text:
- Pavel Minayev (5/10) Jan 08 2002 Suppose you have 100 lines...
- Sean L. Palmer (8/20) Jan 08 2002 So name them foo.d.html ;)
- Russell Borogove (7/19) Jan 08 2002 Suppose you have an editor that can paste a rectangular
- Pavel Minayev (6/9) Jan 08 2002 Well I do hav DevIde. But since it doesn't support D (yet?),
Are nested multiline /* */ comments allowed in D?
Jan 01 2002
no. Use the version statement to block out sections. "Pavel Minayev" <evilone omen.ru> wrote in message news:a0t1rg$kjn$1 digitaldaemon.com...Are nested multiline /* */ comments allowed in D?
Jan 01 2002
"Walter" <walter digitalmars.com> wrote in message news:a0tbj5$ptm$1 digitaldaemon.com...no. Use the version statement to block out sections.Unfortunately, version cannot comment out blocks with bad syntax - which is needed sometimes. For example, I occasionally start writing something, then decide to try another idea, but comment the unfinished block out rather than deleting it in case I'll revert back to it later... and such a block may have improper syntax (like "if(a == ").
Jan 01 2002
I've been considering making version more tolerant of bad syntax, but it is going to have to count { and } ! "Pavel Minayev" <evilone omen.ru> wrote in message news:a0th24$svc$1 digitaldaemon.com..."Walter" <walter digitalmars.com> wrote in message news:a0tbj5$ptm$1 digitaldaemon.com...no. Use the version statement to block out sections.Unfortunately, version cannot comment out blocks with bad syntax - which is needed sometimes. For example, I occasionally start writing something, then decide to try another idea, but comment the unfinished block out rather than deleting it in case I'll revert back to it later... and such a block may have improper syntax (like "if(a == ").
Jan 01 2002
That's perfect. Surely we can make the brackets nest correctly. Sean "Walter" <walter digitalmars.com> wrote in message news:a0tv8q$15rd$1 digitaldaemon.com...I've been considering making version more tolerant of bad syntax, but itisgoing to have to count { and } ! "Pavel Minayev" <evilone omen.ru> wrote in message news:a0th24$svc$1 digitaldaemon.com..."Walter" <walter digitalmars.com> wrote in message news:a0tbj5$ptm$1 digitaldaemon.com...no. Use the version statement to block out sections.Unfortunately, version cannot comment out blocks with bad syntax - which is needed sometimes. For example, I occasionally start writing something, then decide to try another idea, but comment the unfinished block out rather than deleting it in case I'll revert back to it later... and such a block may have improper syntax (like "if(a == ").
Jan 02 2002
"Walter" <walter digitalmars.com> wrote in message news:a0tv8q$15rd$1 digitaldaemon.com...I've been considering making version more tolerant of bad syntax, but itisgoing to have to count { and } !Still... what's wrong with nested comments? It's really funny to see that, even though ANSI commitee didn't make them standart, most C++ compilers around have a switch which enables them. It's not so hard to implement, but could be a useful thing!
Jan 02 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:a0ujps$1iqj$1 digitaldaemon.com..."Walter" <walter digitalmars.com> wrote in message news:a0tv8q$15rd$1 digitaldaemon.com...I'd like to try using the version statement unless it really reaches a dead end.I've been considering making version more tolerant of bad syntax, but itisgoing to have to count { and } !Still... what's wrong with nested comments? It's really funny to see that, even though ANSI commitee didn't make them standart, most C++ compilers around have a switch which enables them. It's not so hard to implement, but could be a useful thing!
Jan 02 2002
Walter wrote:"Pavel Minayev" <evilone omen.ru> wrote in message news:a0ujps$1iqj$1 digitaldaemon.com...... And we have to resort to using a pre-processor! BTW, I've used M4 for years to do stuff other preprocessors failed to do for me. I'll probably find uses for M4 with D as well. Perhaps weeding out code that should not be compiled is a valid use. Otherwise, all the code you feed in should get compiled, right? -BobC"Walter" <walter digitalmars.com> wrote in message news:a0tv8q$15rd$1 digitaldaemon.com...I'd like to try using the version statement unless it really reaches a dead end.I've been considering making version more tolerant of bad syntax, but itisgoing to have to count { and } !Still... what's wrong with nested comments? It's really funny to see that, even though ANSI commitee didn't make them standart, most C++ compilers around have a switch which enables them. It's not so hard to implement, but could be a useful thing!
Jan 02 2002
"Robert W. Cunningham" <rwc_2001 yahoo.com> wrote in message news:3C33BF45.187E8D57 yahoo.com...BTW, I've used M4 for years to do stuff other preprocessors failed to doforme. I'll probably find uses for M4 with D as well. Perhaps weeding outcodethat should not be compiled is a valid use. Otherwise, all the code youfeedin should get compiled, right?Nope, version and debug statements don't compile the code if the condition is not satisfied.
Jan 03 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:a0ujps$1iqj$1 digitaldaemon.com..."Walter" <walter digitalmars.com> wrote in message news:a0tv8q$15rd$1 digitaldaemon.com...Yes indeed, what *is* wrong with nested comments? It seems almost no language supports it (C/C++, Java, Pascal, HTML, D?) but why? Is it that difficult to implement? Is it a feature that would easily be misused? Is there something I am totally missing? Personally I think one of the very big disadvantages of all the languages mentioned above is their lack of nested comments. It is just so easy to comment out a block of code for debugging purposes with the /* and */ comments...I never ever use /* and */ for normal comments, because then I 'lose' the option to comment out blocks of code. So when I write a function header comment, it looks like this: // =================================== // Print ([in] char[] string) // // DESCRIPTION: Prints out the string argument to stdout // ARGUMENT: string: The string to print // RETURNS: - // EXCEPTIONS: - // ---------------------------------------------------- Something like that... I would rather want to use /* */ but because they can't be nested it causes all kinds of problems, so I avoid using them for normal comments at all. Worse still, when I get someone elses code, who does use /* and */ I am in trouble... So I beg you, please make the comments nest...It would solve a lot of problems (for me). -- Stijn OddesE_XYZ hotmail.com http://www.OddesE.f2s.com __________________________________________ Remove _XYZ from my address when replying by mailI've been considering making version more tolerant of bad syntax, but itisgoing to have to count { and } !Still... what's wrong with nested comments? It's really funny to see that, even though ANSI commitee didn't make them standart, most C++ compilers around have a switch which enables them. It's not so hard to implement, but could be a useful thing!
Jan 17 2002
Worse still, when I get someone elses code, who does use /* and */ I am in trouble...Just use #if 0 /* Commented out code */ #endif
Jan 17 2002
"Martin York" <Martin.York veritas.com> wrote in message news:a27ara$nbl$1 digitaldaemon.com...Just use #if 0 /* Commented out code */ #endifD doesn't have preprocessor! One could use the version() blocks but they require correct code syntax inside themselves, so it's just a partial solution.
Jan 17 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:a27b0o$nl7$1 digitaldaemon.com..."Martin York" <Martin.York veritas.com> wrote in message news:a27ara$nbl$1 digitaldaemon.com...Maybe this is a feature that needs to be added to languages (in general) The ability to "comment" out sections of code for debugging purposes, but that refuses to compile in release mode. Just a thought. MartinJust use #if 0 /* Commented out code */ #endifD doesn't have preprocessor! One could use the version() blocks but they require correct code syntax inside themselves, so it's just a partial solution.
Jan 17 2002
"Martin York" <Martin.York veritas.com> wrote in message news:a27fv5$quv$1 digitaldaemon.com...Maybe this is a feature that needs to be added to languages (in general) The ability to "comment" out sections of code for debugging purposes, but that refuses to compile in release mode.D has this, in form of debug() statement (RTFM!). Comments, however, can be used for lots other purposes. BTW an alternative to nested comments could be another, alternative, syntax - like in Pascal where most people use { } for "normal" comments and (* *) to comment out unneeded blocks of code. I have no ideas how this could look though.
Jan 17 2002
On Thu, 17 Jan 2002 20:02:24 +0000, OddesE wrote:Yes indeed, what *is* wrong with nested comments? It seems almost no language supports it (C/C++, Java, Pascal, HTML, D?) but why? Is it that difficult to implement? Is it a feature that would easily be misused? Is there something I am totally missing?What about a type of comment which can be nested but which forces you to state explicitly that you are nesting? For example, say normal comments look like this: /* ........ */ Nested comments could have a label at the start which has to correspond to one at the end: /*1 ... /*2 .... /*4 ...... ..... 4*/ .... 2*/ .... 1*/
Jan 18 2002
Ben Cohen wrote:On Thu, 17 Jan 2002 20:02:24 +0000, OddesE wrote:Sounds like more complexity to no benefit. It's not hard to support nesting of /* */ comments in a compiler (change the parser's are-we-in-a-comment logic to be semantically integer instead of semantically boolean) -- I present the large number of C compilers which have offered this as an option over the years. Nested comments seem unlikely to create obscure errors, because the file won't compile until you have balanced /* */. Existing code which has /* /* */ in it should produce an error message which could hint at the probable cause and solution. The only downside I can see is that at some point your editor's syntax highlighting and your compiler's rules might be at odds as to whether comments are nestable, which would be confusing. But then, I *never* use /* */ comments when I can use // instead. -RBYes indeed, what *is* wrong with nested comments? It seems almost no language supports it (C/C++, Java, Pascal, HTML, D?) but why? Is it that difficult to implement? Is it a feature that would easily be misused? Is there something I am totally missing?What about a type of comment which can be nested but which forces you to state explicitly that you are nesting? For example, say normal comments look like this: /* ........ */ Nested comments could have a label at the start which has to correspond to one at the end: /*1 ... /*2 .... /*4 ...... ..... 4*/ .... 2*/ .... 1*/
Jan 18 2002
"Russell Borogove" <kaleja estarcion.com> wrote in message news:3C486312.90800 estarcion.com...But then, I *never* use /* */ comments when I can use // instead.Who does? But it happens when I first comment out a 10-line loop with /* */ (too lazy to use //s for that =)), and then I want to comment out the entire 100-line function and have to use #ifdef
Jan 18 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:a29q8c$2l9t$1 digitaldaemon.com..."Russell Borogove" <kaleja estarcion.com> wrote in message news:3C486312.90800 estarcion.com...On the other side, personally, most of the times I comment something out, I want to put an alternative piece of code. Thanks to the fact that C++ uses non-nested comments, I can do the following: --- /* Code 1 /*/ Code 2 //*/ --- Code 1 is commented out, while Code 2 is not. Then, I can add a forward slash at the beginning of the first line to uncomment code 1 and comment code 2. Very useful. Cannot be done with nested comments, though. Ideally, D could provide something like: --- comment(1) { case 1: Code 1 case 2: Code 2 } --- You'd then be able to change the number (or identifier, or whatever) inside the comment parenthesis. This would need to have tokenizable contents within the braces, of course, but no parsing or semantic checks (no matching of identifiers and such) would need to be done, which makes it perfect for commenting-out code. Salutaciones, JCABBut then, I *never* use /* */ comments when I can use // instead.Who does? But it happens when I first comment out a 10-line loop with /* */ (too lazy to use //s for that =)), and then I want to comment out the entire 100-line function and have to use #ifdef
Jan 18 2002
"Juan Carlos Arevalo Baeza" <jcab roningames.com> wrote in message news:a2afk9$2ia$1 digitaldaemon.com...On the other side, personally, most of the times I comment somethingout,I want to put an alternative piece of code. Thanks to the fact that C++usesnon-nested comments, I can do the following: --- /* Code 1 /*/ Code 2 //*/ --- Code 1 is commented out, while Code 2 is not. Then, I can add a forward slash at the beginning of the first line to uncomment code 1 and comment code 2. Very useful. Cannot be done with nested comments, though.Never thought of it... a nice trick! Well... looks like a draw =)
Jan 18 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:a2ag5i$30n$1 digitaldaemon.com..."Juan Carlos Arevalo Baeza" <jcab roningames.com> wrote in message news:a2afk9$2ia$1 digitaldaemon.com...:) I couldn't believe it when I found it...--- /* Code 1 /*/ Code 2 //*/ ---Never thought of it... a nice trick!Well... looks like a draw =)My point was... it needs not be. We're abusing the comment feature of the language for a purpose for which it was not designed. Instead, the language should provide an appropriate way to do it. Like above. It already does, actually: version {} Only it'd be nice to be able to specify sub-blocks and select one for uncommenting, all in the same place. Maybe there's a way, I haven't really played with it much. Salutaciones, JCAB
Jan 18 2002
"Juan Carlos Arevalo Baeza" <jcab roningames.com> wrote in message news:a2afk9$2ia$1 digitaldaemon.com...Ideally, D could provide something like: --- comment(1) { case 1: Code 1 case 2: Code 2 } --- You'd then be able to change the number (or identifier, or whatever) inside the comment parenthesis. This would need to have tokenizablecontentswithin the braces, of course, but no parsing or semantic checks (nomatchingof identifiers and such) would need to be done, which makes it perfect for commenting-out code.That's pretty much just what D does do with the 'version' statement.
Jan 20 2002
"Russell Borogove" <kaleja estarcion.com> wrote in message news:3C486312.90800 estarcion.com...But then, I *never* use /* */ comments when I can use // instead.Then you're covered. Use // for normal commenting, and then /* */ is available for commenting out blocks of code.
Jan 20 2002
You still can't comment out a block that contains other commented-out blocks. Sean "Walter" <walter digitalmars.com> wrote in message news:a2dvi7$2fed$2 digitaldaemon.com..."Russell Borogove" <kaleja estarcion.com> wrote in message news:3C486312.90800 estarcion.com...But then, I *never* use /* */ comments when I can use // instead.Then you're covered. Use // for normal commenting, and then /* */ is available for commenting out blocks of code.
Jan 20 2002
True. "Sean L. Palmer" <spalmer iname.com> wrote in message news:a2e7nf$2k7h$1 digitaldaemon.com...You still can't comment out a block that contains other commented-out blocks. Sean "Walter" <walter digitalmars.com> wrote in message news:a2dvi7$2fed$2 digitaldaemon.com..."Russell Borogove" <kaleja estarcion.com> wrote in message news:3C486312.90800 estarcion.com...But then, I *never* use /* */ comments when I can use // instead.Then you're covered. Use // for normal commenting, and then /* */ is available for commenting out blocks of code.
Jan 20 2002
I'd like to take the other side of this argument and say that comments should *not* nest. Here are my reasons: 1. D follows the C /* */ comment convention. Features taken from other languages should be kept the same unless there is a d*** good reason to change them. 2. Using comments to "comment out" code is not a d*** good reason. In fact it's not even a good reason. 3. For "commenting out" code, I've taken to using if(0){ unused code here... } (sometimes without the braces if only one line is being removed). It works great! 4. If you want to do weird things like comment out the last half of one function body and the first half of another, shame on you. The language should not be adapted one angstrom to support such nonsense. 5. Clearly there are cases were the if(0){ ... } style doesn't work. So what? Comments are for commenting programs, not for program versioning. If what's being done is complicated enough so that the simple if(0){ ... } form doesn't cover it, then it's complicated enough to spend some time and give some thought to what it is that needs expressing and how to express it. It's hard to find something worse than code that's gone through iteration after iteration of take out this, take out that, meanwhile leaving all the previous code version (comments included) present. As in regular writing, if the simple rules don't cover it, rewrite! Summary: use comment delimiters to write comments, and only to write comments. Use other mechanisms (and D has several good ones) to remove obsolete code. If comment delimiters are used only to write comments, it's better to stick with non-nesting comments. "OddesE" <OddesE_XYZ hotmail.com> writes:"Pavel Minayev" <evilone omen.ru> wrote in message news:a0ujps$1iqj$1 digitaldaemon.com..."Walter" <walter digitalmars.com> wrote in message news:a0tv8q$15rd$1 digitaldaemon.com...Yes indeed, what *is* wrong with nested comments? It seems almost no language supports it (C/C++, Java, Pascal, HTML, D?) but why? Is it that difficult to implement? Is it a feature that would easily be misused? Is there something I am totally missing? Personally I think one of the very big disadvantages of all the languages mentioned above is their lack of nested comments. It is just so easy to comment out a block of code for debugging purposes with the /* and */ comments...I never ever use /* and */ for normal comments, because then I 'lose' the option to comment out blocks of code. So when I write a function header comment, it looks like this: // =================================== // Print ([in] char[] string) // // DESCRIPTION: Prints out the string argument to stdout // ARGUMENT: string: The string to print // RETURNS: - // EXCEPTIONS: - // ---------------------------------------------------- Something like that... I would rather want to use /* */ but because they can't be nested it causes all kinds of problems, so I avoid using them for normal comments at all. Worse still, when I get someone elses code, who does use /* and */ I am in trouble... So I beg you, please make the comments nest...It would solve a lot of problems (for me). -- Stijn OddesE_XYZ hotmail.com http://www.OddesE.f2s.com __________________________________________ Remove _XYZ from my address when replying by mailI've been considering making version more tolerant of bad syntax, but itisgoing to have to count { and } !Still... what's wrong with nested comments? It's really funny to see that, even though ANSI commitee didn't make them standart, most C++ compilers around have a switch which enables them. It's not so hard to implement, but could be a useful thing!
Jan 18 2002
<la7y6nvo shamko.com> wrote in message news:s7cu1tj4430.fsf michael.shamko.com...I'd like to take the other side of this argument and say that comments should *not* nest. Here are my reasons: 1. D follows the C /* */ comment convention. Features taken from other languages should be kept the same unless there is a d*** good reason to change them.D has quite a lot of changes from C. Just to remember syntax used to declare pointers...2. Using comments to "comment out" code is not a d*** good reason. In fact it's not even a good reason.A debateful statement it is.3. For "commenting out" code, I've taken to using if(0){ unused code here... } (sometimes without the braces if only one line is being removed). It works great!Try to comment out a function like that!4. If you want to do weird things like comment out the last half of one function body and the first half of another, shame on you. The language should not be adapted one angstrom to support such nonsense.Why not, if it's a practical situation?5. Clearly there are cases were the if(0){ ... } style doesn't work. So what? Comments are for commenting programs, not for program versioning. If what's being done is complicated enough so that the simple if(0){ ... } form doesn't cover it, then it's complicated enough to spend some time and give some thought to what it is that needs expressing and how to express it. It's hard to find something worse than code that's gone through iteration after iteration of take out this, take out that, meanwhile leaving all the previous code version (comments included) present. As in regular writing, if the simple rules don't cover it, rewrite!I don't leave the code present. I might start doing it one way, then understand that there _might_ be a better one... so I comment out what I have, implement it in the "better" way, and either remove the comment or the new code depending on whether it works or not.
Jan 18 2002
In response to the dicussion between la7y6nvo and Pavel, I would like to add some more points... "Pavel Minayev" <evilone omen.ru> wrote in message news:a2afp4$2ji$1 digitaldaemon.com...<la7y6nvo shamko.com> wrote in message news:s7cu1tj4430.fsf michael.shamko.com...Nesting comments is a very small change, that is immediately obvious when you try to misuse it, and therefore doesn't form a huge obstacle. Furthermore, people programming in D will have to learn D anyhow, because there are a lot of things that have changed significantly. I agree that changing something just a little bit should have a very good reason, but I personally think including nested comments is.I'd like to take the other side of this argument and say that comments should *not* nest. Here are my reasons: 1. D follows the C /* */ comment convention. Features taken from other languages should be kept the same unless there is a d*** good reason to change them.D has quite a lot of changes from C. Just to remember syntax used to declare pointers...Definitely. I personally do it all the time, and so do most other programmers I know. It is just very convenient.2. Using comments to "comment out" code is not a d*** good reason. In fact it's not even a good reason.A debateful statement it is.There is a big difference between these two methods. When I comment out code, I *remove* that code from the program. When you use the if (0) technique you just make sure it does not run. Worse still, another programmer is going to have a hard time trying to figure out why you wrote a piece of code that is never going to be executed. It is very obvious that if code is commented out, it probably was replaced by other code, or is no longer neccesary.3. For "commenting out" code, I've taken to using if(0){ unused code here... } (sometimes without the braces if only one line is being removed). It works great!Try to comment out a function like that!nonsense.4. If you want to do weird things like comment out the last half of one function body and the first half of another, shame on you. The language should not be adapted one angstrom to support suchWhy not, if it's a practical situation?That would be a wierd situation, but you can already easily do that without nested comments...The language doesn't have to be adapted at all, it already supports such 'nonsense'!take5. Clearly there are cases were the if(0){ ... } style doesn't work. So what? Comments are for commenting programs, not for program versioning. If what's being done is complicated enough so that the simple if(0){ ... } form doesn't cover it, then it's complicated enough to spend some time and give some thought to what it is that needs expressing and how to express it. It's hard to find something worse than code that's gone through iteration after iteration ofDefinitely! Or trying to find out if a piece of code causes a bug by commenting it out, or rewriting a function for efficiency without throwing it away. But there is one big point that la7y6nvo is making that I wholeheartedly agree with:out this, take out that, meanwhile leaving all the previous code version (comments included) present. As in regular writing, if the simple rules don't cover it, rewrite!I don't leave the code present. I might start doing it one way, then understand that there _might_ be a better one... so I comment out what I have, implement it in the "better" way, and either remove the comment or the new code depending on whether it works or not.Totally agreed! Comments where designed with the purpose of commenting on what you are doing in a piece of code. However, practice has shown that programmers want a way to easily remove pieces of code from a program, without actually totally removing it from the source text. Maybe there should indeed be introduced a new type of 'comments' (or should I say removers?), that do nest. They could be highlighted with a different color in the editor, and then /* */ would be restored to it's original purpose, commenting on code. At the moment, most experienced programmers avoid using /* */ altogether, even when it's use would be very practical, to keep the option of using them for commenting out pieces of code. I am for simply nesting the existing /* */, but another way of 'removing' code would be good to. -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net __________________________________________ Remove _XYZ from my address when replying by mailComments are for commenting programs, not for program versioning.
Jan 19 2002
"OddesE" <OddesE_XYZ hotmail.com> ha scritto nel messaggio news:a2cusb$1q0c$1 digitaldaemon.com... [...]But there is one big point that la7y6nvo is making that I wholeheartedly agree with:And the JavaDOC-like tool question you wrote in the other post is another good argument. Nesting or non-nesting is not the real question. We need a simple way to comment-out code. In C/C++ i would use #if 0, but in D there is nothing like that... CiaoTotally agreed! Comments where designed with the purpose of commenting on what you are doing in a piece of code. However, practice has shown that programmers want a way to easily remove pieces of code from a program, without actually totally removing it from the source text. Maybe there should indeed be introduced a new type of 'comments' (or should I say removers?), that do nest. They could be highlighted with a different color in the editor, and then /* */ would be restored to it's original purpose, commenting on code. At the moment, most experienced programmers avoid using /* */ altogether, even when it's use would be very practical, to keep the option of using them for commenting out pieces of code. I am for simply nesting the existing /* */, but another way of 'removing' code would be good to.Comments are for commenting programs, not for program versioning.
Jan 21 2002
<la7y6nvo shamko.com> wrote in message news:s7cu1tj4430.fsf michael.shamko.com...3. For "commenting out" code, I've taken to using if(0){ unused code here... } (sometimes without the braces if only one line is being removed). It works great!I use that too. But I keep getting grief from various compilers that insist I must have made a mistake having a constant in a conditional. Notably, DMC does *not* issue warnings about that construct! That form was the genesis of the version statement in D. (I wanted it to work with declarations, too, and not introduce a new scope in the { }. Using a new keyword made it greppable, and allowed some other semantic tweaking to make it work nice.)
Jan 20 2002
<SNIP>I would rather want to use /* */ but because they can't be nested it causes all kinds of problems, so I avoid using them for normal comments at all. Worse still, when I get someone elses code, who does use /* and */ I am in trouble...<SNIP> I just thought of something else... What about tools like JavaDoc (or the future DDoc), which require documentation to start with /** and end with */ ? Now you can kiss using /* */ for removing code goodbye...A major nuisance. -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net __________________________________________ Remove _XYZ from my address when replying by mail
Jan 19 2002
"OddesE" <OddesE_XYZ hotmail.com> wrote in message news:a2cuup$1q1a$1 digitaldaemon.com...I just thought of something else... What about tools like JavaDoc (or the future DDoc), which require documentation to start with /** and end with */ ? Now you can kiss using /* */ for removing code goodbye...A major nuisance.Why? If it uses /** */, why can't I use /* */ ?
Jan 19 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:a2dnv9$29hv$1 digitaldaemon.com..."OddesE" <OddesE_XYZ hotmail.com> wrote in message news:a2cuup$1q1a$1 digitaldaemon.com...If you have functions with documentation like this: /** Documentation for Func1 */ void Func1() { // ... } /** Documentation for Func2 */ void Func2() { // ... } You can't comment both of them out at once using /* */. You would have to comment out both of them seperately. This could be done in all these kinds of situations, but I would like comments to nest to make it easier to comment out large blocks at once. Think of a class that you want to comment out...Gets problematic if you have documented your functions using JavaDoc style /** */.... -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net __________________________________________ Remove _XYZ from my address when replying by mailI just thought of something else... What about tools like JavaDoc (or the future DDoc), which require documentation to start with /** and end with */ ? Now you can kiss using /* */ for removing code goodbye...A major nuisance.Why? If it uses /** */, why can't I use /* */ ?
Jan 20 2002
"Pavel Minayev" <evilone omen.ru> ha scritto nel messaggio news:a0th24$svc$1 digitaldaemon.com..."Walter" <walter digitalmars.com> wrote in message news:a0tbj5$ptm$1 digitaldaemon.com...I also often need nested comments as a fast way to comment-out weird code. To me seems better to define a new style of comment to comment out big blocks of code (or a block of natural language description). This new "wipe-out" comment must be clearly visible and we can choose it can be nested (it's new, so noone should complain). I think to something like:no. Use the version statement to block out sections.Unfortunately, version cannot comment out blocks with bad syntax - which is needed sometimes. For example, I occasionally start writing something, then decide to try another idea, but comment the unfinished block out rather than deleting it in case I'll revert back to it later... and such a block may have improper syntax (like "if(a == ")... big block of text, with nested > and < ... < I like to think this comment must be at column 0, so it's easy to distinguish from normal code Ciao.
Jan 07 2002
"Roberto Mariottini" <rmariottini lycosmail.com> wrote in message news:a1ck0f$1alu$1 digitaldaemon.com...Maybe then < > ?.. big block of text, with nested > and < ... <
Jan 07 2002
Roberto Mariottini wrote:"Pavel Minayev" <evilone omen.ru> ha scritto nel messaggio news:a0th24$svc$1 digitaldaemon.com...Insert the text: //weirdcode// at the beginning of each line. Or, use the D-in-HTML feature and comment out large chunks with <!-- ... --> -RB"Walter" <walter digitalmars.com> wrote in message news:a0tbj5$ptm$1 digitaldaemon.com...I also often need nested comments as a fast way to comment-out weird code. To me seems better to define a new style of comment to comment out big blocks of code (or a block of natural language description)....no. Use the version statement to block out sections.Unfortunately, version cannot comment out blocks with bad syntax - which is needed sometimes. For example, I occasionally start writing something, then decide to try another idea, but comment the unfinished block out rather than deleting it in case I'll revert back to it later... and such a block may have improper syntax (like "if(a == ")... big block of text, with nested > and < ... < I like to think this comment must be at column 0, so it's easy to distinguish from normal code
Jan 07 2002
"Russell Borogove" <kaleja estarcion.com> wrote in message news:3C3A713E.4050605 estarcion.com...Insert the text: //weirdcode// at the beginning of each line.Suppose you have 100 lines...Or, use the D-in-HTML feature and comment out large chunks with <!-- ... -->For this to work, file must have .html extension. I personally prefer .d =)
Jan 08 2002
So name them foo.d.html ;) Might be nice for D compiler to automatically detect a <html> tag and assume it should start parsing HTML automagically until it finds a </html>. So long as Walter never wants to use C++ template syntax this shouldn't be a problem. Then you can just use foo.d as your file name. Sean "Pavel Minayev" <evilone omen.ru> wrote in message news:a1egsp$2g3g$1 digitaldaemon.com..."Russell Borogove" <kaleja estarcion.com> wrote in message news:3C3A713E.4050605 estarcion.com...Insert the text: //weirdcode// at the beginning of each line.Suppose you have 100 lines...Or, use the D-in-HTML feature and comment out large chunks with <!-- ... -->For this to work, file must have .html extension. I personally prefer .d =)
Jan 08 2002
Pavel Minayev wrote:"Russell Borogove" <kaleja estarcion.com> wrote in message news:3C3A713E.4050605 estarcion.com...Suppose you have an editor that can paste a rectangular selection and drop down to the same column on the next line in a single keystroke. (Dev Studio, for example) Anyway, that's what works for me, and I understand it doesn't work for everybody. -RBInsert the text: //weirdcode// at the beginning of each line.Suppose you have 100 lines...
Jan 08 2002
"Russell Borogove" <kaleja estarcion.com> wrote in message news:3C3B64F8.4070003 estarcion.com...Suppose you have an editor that can paste a rectangular selection and drop down to the same column on the next line in a single keystroke. (Dev Studio, for example)Well I do hav DevIde. But since it doesn't support D (yet?), I have to use the FAR built-in editor + Colorer plug-in, after writing a highlighting scheme for D. Unfortunately, this editor doesn't support tricks like the one you mentioned...
Jan 08 2002