January 19, 2002 Re: nested comments? | ||||
---|---|---|---|---|
| ||||
Posted in reply to OddesE | <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 |
January 20, 2002 Re: nested comments? | ||||
---|---|---|---|---|
| ||||
Posted in reply to OddesE | "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 /* */ ? |
January 20, 2002 Re: nested comments? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russell Borogove | "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. |
January 20, 2002 Re: nested comments? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Juan Carlos Arevalo Baeza | "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 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. That's pretty much just what D does do with the 'version' statement. |
January 20, 2002 Re: nested comments? | ||||
---|---|---|---|---|
| ||||
Posted in reply to la7y6nvo | <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.) |
January 20, 2002 Re: nested comments? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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. |
January 20, 2002 Re: nested comments? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "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... > > > 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 /* */ ? > 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 mail |
January 21, 2002 Re: nested comments? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | 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. > > > |
January 21, 2002 Re: nested comments? | ||||
---|---|---|---|---|
| ||||
Posted in reply to OddesE | "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: > > >>Comments are for commenting programs, not > >>for program versioning. > > 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. 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... Ciao |
Copyright © 1999-2021 by the D Language Foundation