D - nesting comments?
- Mark Shackelford (11/11) Aug 16 2001 Hi!
- Walter (9/20) Aug 16 2001 To comment out a large block of code:
- Matt Busigin (3/12) Aug 16 2001 This is not good enough - what about commenting out functions? Global
- Walter (5/17) Aug 16 2001 To comment out a function, you can wrap its entire code body with if(0){...
- Angus Graham (11/14) Aug 16 2001 So to comment out a section of code I would have to change three lines i...
- Kent Sandvik (5/8) Aug 16 2001 I've always had problems with nested comments, the 'if 0' trick works ju...
- Erik Rounds (12/20) Aug 22 2001 is there any reason why comments should not be able to be nested? As lo...
- Walter (8/30) Aug 23 2001 Making it work is easy. The trouble is that C/C++ programmers are so use...
- Rajiv Bhagwat (10/45) Aug 23 2001 How about clear indication on the comment, based on the 'clipprep' style...
- Dan Hursh (10/30) Aug 23 2001 Is this true of most C/C++ programmers? If I get confused about this
- Russell Bornschlegel (7/15) Aug 24 2001 Back in the day, I believe Turbo C allowed a compiler switch to
- Walter (7/23) Aug 16 2001 if(0){}.
- Sean L. Palmer (14/17) Oct 28 2001 Programmers these days should be using a decent code editor, with syntax
- rogalsky (11/13) Aug 17 2001 a decent editor can comment out whole block with "//" ...
- Sheldon Simms (18/38) Aug 17 2001 maybe there should just be an ignore block...
- Christophe de Dinechin (25/32) Aug 17 2001 As a compiler implementor, this makes me jump through the roof. In engli...
- Walter (9/19) Aug 20 2001 has
Hi! With neither nesting comments nor preprocessor #if 0 / #endif available, how would a D programmer comment out a large section of code that contains multiline /* */ comments? It won't work. This would force everyone to use // comments everywhere just to be able at some future point to comment out blocks of code. Either make /* ... */ nest, or add another nesting comment type. You know, the evil Modula (* ... *) kind. ;^) Cheers! -- Mark Shackelford
Aug 16 2001
To comment out a large block of code: if (0) { ... block of code ... } The code must be syntactically correct, but not semantically correct. -Walter "Mark Shackelford" <mark shackelford-family.org> wrote in message news:3B7C4DD2.8B5E9470 shackelford-family.org...Hi! With neither nesting comments nor preprocessor #if 0 / #endif available, how would a D programmer comment out a large section of code that contains multiline /* */ comments? It won't work. This would force everyone to use // comments everywhere just to be able at some future point to comment out blocks of code. Either make /* ... */ nest, or add another nesting comment type. You know, the evil Modula (* ... *) kind. ;^) Cheers! -- Mark Shackelford
Aug 16 2001
Walter wrote:To comment out a large block of code: if (0) { ... block of code ... } The code must be syntactically correct, but not semantically correct. -WalterThis is not good enough - what about commenting out functions? Global declarations?
Aug 16 2001
"Matt Busigin" <mbusigin helios.spang.org.uk> wrote in message news:3B7C4B0D.1040504 helios.spang.org.uk...Walter wrote:To comment out a function, you can wrap its entire code body with if(0){}. The function will still be there, but there'll be no code in it. Otherwise, you can use the debug attribute to get rid of blocks of declarations.To comment out a large block of code: if (0) { ... block of code ... } The code must be syntactically correct, but not semantically correct. -WalterThis is not good enough - what about commenting out functions? Global declarations?
Aug 16 2001
"Walter" <walter digitalmars.com> wrote in message news:9lhng3To comment out a function, you can wrap its entire code body with if(0){}. The function will still be there, but there'll be no code in it.Otherwise,you can use the debug attribute to get rid of blocks of declarations.So to comment out a section of code I would have to change three lines in every function. That sucks! I don't understand - a decent editor colours comments so there's no question of which parts are commented out. I'm totally naive when it comes to compiler implementation, but I can't imagine how nested comments would complicate things on the implementation side. So why not allow them? Angus Graham
Aug 16 2001
"Angus Graham" <agraham_d agraham.ca> wrote in message news:9lhphi$bts$1 digitaldaemon.com...I'm totally naive when it comes to compiler implementation, but I can't imagine how nested comments would complicate things on the implementation side.I've always had problems with nested comments, the 'if 0' trick works just fine, lack of nested comments would not be a big minus for me when shopping for a good language. --Kent
Aug 16 2001
is there any reason why comments should not be able to be nested? As long as the number of /* match the number of */ I don't see any problem. ie. /* commented code 1 /* commented code 2 */ commented code 3 */ Why can't this be made to work? Just increment a comment counter when a /* is recieved and decrement it on a */. Thanks. Kent Sandvik wrote:"Angus Graham" <agraham_d agraham.ca> wrote in message news:9lhphi$bts$1 digitaldaemon.com...I'm totally naive when it comes to compiler implementation, but I can't imagine how nested comments would complicate things on the implementation side.I've always had problems with nested comments, the 'if 0' trick works just fine, lack of nested comments would not be a big minus for me when shopping for a good language. --Kent
Aug 22 2001
Making it work is easy. The trouble is that C/C++ programmers are so used to them not nesting, it can introduce bugs that are difficult to spot. Erik Rounds wrote in message <3B83D77C.9ABB335C aatrix.com>...is there any reason why comments should not be able to be nested? As longasthe number of /* match the number of */ I don't see any problem. ie. /* commented code 1 /* commented code 2 */ commented code 3 */ Why can't this be made to work? Just increment a comment counter when a /*isrecieved and decrement it on a */. Thanks. Kent Sandvik wrote:implementation"Angus Graham" <agraham_d agraham.ca> wrote in message news:9lhphi$bts$1 digitaldaemon.com...I'm totally naive when it comes to compiler implementation, but I can't imagine how nested comments would complicate things on thejustside.I've always had problems with nested comments, the 'if 0' trick worksshoppingfine, lack of nested comments would not be a big minus for me whenfor a good language. --Kent
Aug 23 2001
How about clear indication on the comment, based on the 'clipprep' style: %a{ ,,............ %b{............. %b} ................. %a} Where the comments have 1 char identifier associated with them. -- Rajiv Walter <walter digitalmars.com> wrote in message news:9m2bil$1unn$2 digitaldaemon.com...Making it work is easy. The trouble is that C/C++ programmers are so usedtothem not nesting, it can introduce bugs that are difficult to spot. Erik Rounds wrote in message <3B83D77C.9ABB335C aatrix.com>...longis there any reason why comments should not be able to be nested? Asas/*the number of /* match the number of */ I don't see any problem. ie. /* commented code 1 /* commented code 2 */ commented code 3 */ Why can't this be made to work? Just increment a comment counter when aiscan'trecieved and decrement it on a */. Thanks. Kent Sandvik wrote:"Angus Graham" <agraham_d agraham.ca> wrote in message news:9lhphi$bts$1 digitaldaemon.com...I'm totally naive when it comes to compiler implementation, but Iimplementationimagine how nested comments would complicate things on thejustside.I've always had problems with nested comments, the 'if 0' trick worksshoppingfine, lack of nested comments would not be a big minus for me whenfor a good language. --Kent
Aug 23 2001
Is this true of most C/C++ programmers? If I get confused about this it is always because I assume they they do (or should) nest. I have never heard anyone complain about a compiler that did nest them. I know such compilers exist. I just never thought this would be a huge problem for folks to get used to. I doubt it will be that big of a problem for me to get used to it if they don't nest, but nesting seems more logical to me, since you have unique open and close tokens for the comment. Dan Walter wrote:Making it work is easy. The trouble is that C/C++ programmers are so used to them not nesting, it can introduce bugs that are difficult to spot. Erik Rounds wrote in message <3B83D77C.9ABB335C aatrix.com>...[clip]is there any reason why comments should not be able to be nested? As longasthe number of /* match the number of */ I don't see any problem. ie. /* commented code 1 /* commented code 2 */ commented code 3 */ Why can't this be made to work? Just increment a comment counter when a /*isrecieved and decrement it on a */. Thanks.
Aug 23 2001
Dan Hursh wrote:Is this true of most C/C++ programmers? If I get confused about this it is always because I assume they they do (or should) nest. I have never heard anyone complain about a compiler that did nest them. I know such compilers exist. I just never thought this would be a huge problem for folks to get used to. I doubt it will be that big of a problem for me to get used to it if they don't nest, but nesting seems more logical to me, since you have unique open and close tokens for the comment.Back in the day, I believe Turbo C allowed a compiler switch to say whether comments nested. Nesting always seemed more logical and useful to me. Since switching to C++, though, I've never even been tempted to nest comments. -R
Aug 24 2001
"Angus Graham" <agraham_d agraham.ca> wrote in message news:9lhphi$bts$1 digitaldaemon.com..."Walter" <walter digitalmars.com> wrote in message news:9lhng3if(0){}.To comment out a function, you can wrap its entire code body withquestionThe function will still be there, but there'll be no code in it.Otherwise,you can use the debug attribute to get rid of blocks of declarations.So to comment out a section of code I would have to change three lines in every function. That sucks! I don't understand - a decent editor colours comments so there's noof which parts are commented out. I'm totally naive when it comes to compiler implementation, but I can't imagine how nested comments would complicate things on the implementation side. So why not allow them? Angus GrahamThe problem with nested comments is that programmers don't expect them to be nested. BTW, there is nothing in D that prevents the C preprocessor from being run over it if you really miss it (or any other text macro processor)!
Aug 16 2001
Programmers these days should be using a decent code editor, with syntax highlighting, which would show any comment nesting bug right away. Nobody does "copy con: myprogram.d" anymore. ;) Use the tools available to you. If the D spec says they nest, then D programmers will expect them to nest; otherwise they won't. What you decide will *be* what they expect. So decide wisely. You've broken enough C compatibility already that tossing out a tiny bit more won't kill anyone. If you ask me, I say to hell with C/C++ compatibility, make the language nice for its own sake. Otherwise you may as well expect D to do nothing more in the market than possibly influence the next round of ANSI/ISO C++ standards committee because it won't be enough of an improvement to C++ to warrant switching languages. SeanThe problem with nested comments is that programmers don't expect them tobenested. BTW, there is nothing in D that prevents the C preprocessor from being run over it if you really miss it (or any other text macroprocessor)!
Oct 28 2001
Angus Graham wrote:I don't understand - a decent editor colours comments so there's no question of which parts are commented out.a decent editor can comment out whole block with "//" ... -- \\|// (. .) +-----------------------------oOOo-(_)-oOOo----------------------------+ I Dipl. Phys. Olaf Rogalsky Institut f. Theo. Physik I I I Tel.: 09131 8528440 Univ. Erlangen-Nuernberg I I Fax.: 09131 8528444 Staudtstrasse 7 B3 I I rogalsky theorie1.physik.uni-erlangen.de D-91058 Erlangen I +----------------------------------------------------------------------+
Aug 17 2001
Im Artikel <9lhng3$a5d$1 digitaldaemon.com> schrieb "Walter" <walter digitalmars.com>:"Matt Busigin" <mbusigin helios.spang.org.uk> wrote in message news:3B7C4B0D.1040504 helios.spang.org.uk...maybe there should just be an ignore block... class ABC { int this () {...} ignore { int a1 () {...} int a2 () {...} } int b1 () {...} } -- Sheldon Simms / sheldon semanticedge.comWalter wrote:To comment out a function, you can wrap its entire code body with if(0){}. The function will still be there, but there'll be no code in it. Otherwise, you can use the debug attribute to get rid of blocks of declarations.To comment out a large block of code: if (0) { ... block of code ... } The code must be syntactically correct, but not semantically correct. -WalterThis is not good enough - what about commenting out functions? Global declarations?
Aug 17 2001
Walter wrote:To comment out a large block of code: if (0) { ... block of code ... } The code must be syntactically correct, but not semantically correct. -WalterAs a compiler implementor, this makes me jump through the roof. In english: WHAAAT??? Let me combine that with other language features. Since I can reference forward declarations, I can write: void foo() { if (check_stuff) { ... } } void bar() { if (check_stuff) { ... } } const int check_stuff = 0; // make it 1 to enable stuff checking See where I'm going? Now you have to defer semantics of foo and bar until the first-level semantics of every possibly constant declaration in the file has been processes. That's going to be ugly. And last, what is considered a constant declaration? Let me build a corner case: const int check_stuff = (int) &bar - (int) &foo > 1024; Now, you have a recursive constant declaration, which impacts the size of the functions, and depends on it. Good luck processing that ;-) By the way, what if I want to disable a declaration? To remove debugging fields in a struct? Christophe
Aug 17 2001
Christophe de Dinechin wrote in message <3B7D3295.4886A523 earthlink.net>...See where I'm going? Now you have to defer semantics of foo and bar untilthefirst-level semantics of every possibly constant declaration in the filehasbeen processes. That's going to be ugly.No, it's not bad. The compiler makes multiple passes over the syntax tree to do the semantics. That's how forward references are resolved as well.And last, what is considered a constant declaration? Let me build a corner case: const int check_stuff = (int) &bar - (int) &foo > 1024; Now, you have a recursive constant declaration, which impacts the size ofthefunctions, and depends on it. Good luck processing that ;-)A constant declaration is one that the compiler can figure out at compile time <g>.By the way, what if I want to disable a declaration? To remove debugging fields in a struct?Use the debug attribute.
Aug 20 2001