评论风格
下午全部。我只是想知道这一点 - 我用
(一般)用来评论C中的一行,但来自
查看其他人编写的代码似乎有很多人使用/ * * /
(如果我的评论会超过多行,我只会使用) - 确实
单向有什么优势,或者是风格确切
那个风格问题?
干杯,
尼克
----
Mesham并行编程语言
www .mesham.net
Afternoon all. I was just wondering about this point - I have
(generally) used // for commenting a single line in C, but from
looking at code other people have written it seems many use /* */
(which I only use if my comment will be over multiple lines) - does
one way have any advantages over the other, or is the style exactly
that, a question of style?
Cheers,
Nick
----
Mesham Parallel Programming Language
www.mesham.net
polas说:
polas said:
下午全部。我只是想知道这一点 - 我用
(一般)用来评论C中的一行,但来自
查看其他人编写的代码似乎有很多人使用/ * * /
(如果我的评论会超过多行,我只会使用) - 确实
单向有什么优势,或者是风格确切
那样,风格问题?
Afternoon all. I was just wondering about this point - I have
(generally) used // for commenting a single line in C, but from
looking at code other people have written it seems many use /* */
(which I only use if my comment will be over multiple lines) - does
one way have any advantages over the other, or is the style exactly
that, a question of style?
/ * ADVANTAGES * /
* C89符合
*不会换行时断开(例如发布到Usenet的代码!)
*对抗线拼接强大
/ * DISADVANTAGES * /
*罗嗦一点 - 你必须记得关闭它
*没有嵌套
//优点
*嵌套//喜欢//这个
*简洁
// DISADVANTAGES
*不符合C89要求
*在换行时断开(例如发布到Usenet的代码)
*对意外线拼接脆弱:
foo(); //把foo做到c:\our_directory \
bar(); //现在*为什么*这个功能不起作用?
正如你所看到的,一个的好处结果是
的缺点另一个。
对于Usenet,/ * * /是明显的赢家,仅仅是因为断线
问题://这种评论,当你发表一个很长的评论
行作为你在Usenet文章中提供的代码的一部分,代码no
更长时间编译。
-
Richard Heathfield< http://www.cpax.org.uk>
电子邮件:-http:// www。 + rjh @
谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>
Usenet是一个奇怪的放置" - dmr 1999年7月29日
/* ADVANTAGES */
* C89-conforming
* doesn''t break when a line wraps (eg on code posted to Usenet!)
* robust against line-splicing
/* DISADVANTAGES */
* a little on the wordy side - you have to remember to close it
* doesn''t nest
// ADVANTAGES
* nests // like // this
* terse
// DISADVANTAGES
* not C89-conforming
* breaks when a line wraps (eg on code posted to Usenet)
* fragile against accidental line-splicing:
foo(); // do the foo thing to c:\our_directory\
bar(); // now *why* isn''t this function working?
As you can see, the advantages of one turn out to be the disadvantages of
the other.
For Usenet, /* */ is the clear winner, simply because of the line-break
issue: // with this kind of comment, when you post a very long comment
line as part of code that you present in a Usenet article, the code no
longer compiles.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
polas< ni ** @ helpforce.comwrites:
polas <ni**@helpforce.comwrites:
下午全部。我只是想知道这一点 - 我用
(一般)用来评论C中的一行,但来自
查看其他人编写的代码似乎有很多人使用/ * * /
(如果我的评论会超过多行,我只会使用) - 确实
单向有什么优势,或者是风格确切
那个风格问题?
干杯,
尼克
----
Mesham并行编程语言
www .mesham.net
/ *由于多种原因好多了* /
最重要的是你可以由于不同的自动换行设置,它们会被打破多行。
。坦率地说,我也认为它好像b $ b看起来更好:-)
/ ***************
*评论区块
*很棒eh
*************** /
/* is much better for several reasons */
The most important one is that you can enclose multiple lines should
they break due to a different word wrap setting. Frankly I also think it
looks better :-)
/***************
* Comment block
* great eh
***************/
Richard Heathfield< rj *@see.sig.invalidwrites:
Richard Heathfield <rj*@see.sig.invalidwrites:
对于Usenet,/ * * /是明显的赢家,因为换行符
issue://当你发表一篇很长的评论
行作为你在Usenet文章中提供的代码的一部分时,代码no
更长时间编译。
For Usenet, /* */ is the clear winner, simply because of the line-break
issue: // with this kind of comment, when you post a very long comment
line as part of code that you present in a Usenet article, the code no
longer compiles.
或许你应该避免使用自己发布给Usenet的字母包裹代码
。
- -
我错过了什么吗?
--Dan Pop
Or perhaps you should just refrain from word-wrapping code that
you post to Usenet.
--
"Am I missing something?"
--Dan Pop