Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Comments (http://www.chiefdelphi.com/forums/showthread.php?t=24062)

Astronouth7303 18-01-2004 21:15

Comments
 
Question: Why doesn't anyone use single-line comments?

the /* */ doesn't nest.

Like:
Code:

//This is a one line Comment.

/* Commented_Out_Code();
 /* this is a multi-line
    Comment in Code */
 This_Code_Still_Executes(); */

/* Commented_Out_Code();
 // this is a multi-line
 // comment in code
 // split into single-line
 // comments
 This_Code_Dont_Execute(); // :ahh:  */

The reason I say this is that you can use /* */ for commenting out and debugging.

Isn't it good coding practice to do this anyway?

Plus, It isn't in the default code, Anywhere.

KevinB 18-01-2004 21:38

Re: Comments
 
The way I've always understood it was that /* */'s were the only way to use comments in C. When C++ came along, it added the // style comments. Therefore: //'s aren't a part of standard C, only C++.

That probably explains why a lot of people don't use them: they don't expect them to work! However, you are correct in saying that the Microchip compiler does seem to allow them.

So // away!

Rickertsen2 18-01-2004 21:40

Re: Comments
 
Quote:

Originally Posted by Astronouth7303
Question: Why doesn't anyone use single-line comments?

the /* */ doesn't nest.

Like:
Code:

//This is a one line Comment.

/* Commented_Out_Code();
 /* this is a multi-line
    Comment in Code */
 This_Code_Still_Executes(); */

/* Commented_Out_Code();
 // this is a multi-line
 // comment in code
 // split into single-line
 // comments
 This_Code_Dont_Execute(); // :ahh:  */

The reason I say this is that you can use /* */ for commenting out and debugging.

Isn't it good coding practice to do this anyway?

Plus, It isn't in the default code, Anywhere.

I have wondered the same thing. It gets quite annoying trying to comment out blocks of code that contain multiline comments.

Astronouth7303 18-01-2004 21:44

Re: Comments
 
It would seem like Whoever wrote the default code would know about //. :shrug:

I actually got the idea from NQC, a C-like language for LEGO's RCX :]

deltacoder1020 18-01-2004 23:14

Re: Comments
 
my standard practice is to make comments that actually say something single-liners "//", and use "/* */" for commenting out blocks - that way there is no conflict.


All times are GMT -5. The time now is 00:33.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi