D - nested comments?
- "Pavel Minayev" <evilone omen.ru> Jan 01 2002
- "Walter" <walter digitalmars.com> Jan 01 2002
- "Pavel Minayev" <evilone omen.ru> Jan 01 2002
- "Walter" <walter digitalmars.com> Jan 01 2002
- "Sean L. Palmer" <spalmer iname.com> Jan 02 2002
- "Pavel Minayev" <evilone omen.ru> Jan 02 2002
- "Walter" <walter digitalmars.com> Jan 02 2002
- "Robert W. Cunningham" <rwc_2001 yahoo.com> Jan 02 2002
- "Pavel Minayev" <evilone omen.ru> Jan 03 2002
- "OddesE" <OddesE_XYZ hotmail.com> Jan 17 2002
- "Martin York" <Martin.York veritas.com> Jan 17 2002
- "Pavel Minayev" <evilone omen.ru> Jan 17 2002
- "Martin York" <Martin.York veritas.com> Jan 17 2002
- "Pavel Minayev" <evilone omen.ru> Jan 17 2002
- Ben Cohen <bc skygate.co.uk> Jan 18 2002
- Russell Borogove <kaleja estarcion.com> Jan 18 2002
- "Pavel Minayev" <evilone omen.ru> Jan 18 2002
- "Juan Carlos Arevalo Baeza" <jcab roningames.com> Jan 18 2002
- "Pavel Minayev" <evilone omen.ru> Jan 18 2002
- "Walter" <walter digitalmars.com> Jan 20 2002
- "Walter" <walter digitalmars.com> Jan 20 2002
- "Sean L. Palmer" <spalmer iname.com> Jan 20 2002
- "Walter" <walter digitalmars.com> Jan 20 2002
- la7y6nvo shamko.com Jan 18 2002
- "Pavel Minayev" <evilone omen.ru> Jan 18 2002
- "OddesE" <OddesE_XYZ hotmail.com> Jan 19 2002
- "Roberto Mariottini" <rmariottini lycosmail.com> Jan 21 2002
- "Walter" <walter digitalmars.com> Jan 20 2002
- "OddesE" <OddesE_XYZ hotmail.com> Jan 19 2002
- "Pavel Minayev" <evilone omen.ru> Jan 19 2002
- "OddesE" <OddesE_XYZ hotmail.com> Jan 20 2002
- "Roberto Mariottini" <rmariottini lycosmail.com> Jan 07 2002
- "Pavel Minayev" <evilone omen.ru> Jan 07 2002
- Russell Borogove <kaleja estarcion.com> Jan 07 2002
- "Pavel Minayev" <evilone omen.ru> Jan 08 2002
- "Sean L. Palmer" <spalmer iname.com> Jan 08 2002
- Russell Borogove <kaleja estarcion.com> Jan 08 2002
- "Pavel Minayev" <evilone omen.ru> Jan 08 2002
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 it
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 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 it
going 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've been considering making version more tolerant of bad syntax, but it
going 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!
I'd like to try using the version statement unless it really reaches a dead end.
Jan 02 2002
Walter wrote:"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've been considering making version more tolerant of bad syntax, but it
going 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!
I'd like to try using the version statement unless it really reaches a dead end.
... 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
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 do
me. I'll probably find uses for M4 with D as well. Perhaps weeding out
that should not be compiled is a valid use. Otherwise, all the code you
in 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...I've been considering making version more tolerant of bad syntax, but it
going 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!
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 mail
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 */ #endif
D 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...Just use #if 0 /* Commented out code */ #endif
D 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.
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. Martin
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: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*/
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. -RB
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 0 or remove those nested ones... $# %
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...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 0 or remove those nested ones... $# %
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, JCAB
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 something
I want to put an alternative piece of code. Thanks to the fact that C++
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.
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...--- /* Code 1 /*/ Code 2 //*/ ---
Never thought of it... a nice trick!
:) I couldn't believe it when I found it...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 tokenizable
within the braces, of course, but no parsing or semantic checks (no
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.
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...
I've been considering making version more tolerant of bad syntax, but it
going 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!
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 mail
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...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...
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.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.
Definitely. I personally do it all the time, and so do most other programmers I know. It is just very convenient.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!
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.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
Why 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'!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
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.
Definitely! 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: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. -- 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> 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
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...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
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...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 == ").
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:
< 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 < > ?
Jan 07 2002
Roberto Mariottini wrote:"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...no. Use the version statement to block out sections.
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 == ").
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)....
< I like to think this comment must be at column 0, so it's easy to distinguish from normal code
Insert the text: //weirdcode// at the beginning of each line. Or, use the D-in-HTML feature and comment out large chunks with <!-- ... --> -RB
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...Insert the text: //weirdcode// at the beginning of each line.
Suppose you have 100 lines...
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. -RB
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









"Sean L. Palmer" <spalmer iname.com> 