comments

If comments are safe, then why doesn't `x = 0; x+/*cmt*/+;` or `var f/*cmt*/oo = 'foo';` work?

蓝咒 提交于 2019-12-05 02:45:00
问题 This thread inspired the question. Here are the code samples again. I'm looking for an answer that tells exactly what is going on. Both x = 0; x+/*cmt*/+; and var f/*cmt*/oo = 'foo'; produce syntax errors, which renders the answers in this question wrong. 回答1: From ECMAScript reference : Comments behave like white space and are discarded except that, if a MultiLineComment contains a line terminator character, then the entire comment is considered to be a LineTerminator for purposes of parsing

Is it ok to put comments about bug fixes in the source code?

淺唱寂寞╮ 提交于 2019-12-05 02:43:57
And if so, where do you draw the line? My coworkers and I disagree on this subject. I have seen such things as // fixes bug # 22 to // fixed bug: shouldnt be decrementing i++; Is it ok if the change is fairly significant, and radically changes what the method was written to do? Or do you simply change the summary text of the method to reflect what it is now meant to do? My opinion is that this information should be put into source control. Some state that this is bad because then it will be lost outside of the context of source control (say you switch systems and want to keep historical data).

Why does “<! --” comment out a style rule, but “<!--” does not?

限于喜欢 提交于 2019-12-05 02:21:46
Take it easy on me. I am just learning HTML. Accroding to http://www.w3.org/TR/html-markup/syntax.html#comments and many other sites I've seen such as this http://www.w3schools.com/tags/tag_comment.asp they say an HTML comment is <!-- text --> with no space between ! and the next dash. Yet, I show below that only when I write <! -- test --> is the stuff inside be actually gets ignored. Notice the space added between <! and -- Here is the HTML code <!DOCTYPE HTML> <html> <head> <style type="text/css"> <!-- td {border: 1px solid gray;} --> </style> </head> <body> <table> <tr> <td> test </td> <

Can the Pluggable Annotation Processor API retrieve source code comments?

倾然丶 夕夏残阳落幕 提交于 2019-12-05 01:30:30
I am using the pluggable annotation processing api withing Java6+ to automatically create some deployment XML files. Part of these XML files contains a description of the object. The description is ALWAYS the same content as the Javadoc associated with the class itself. I could force the comment to be a field of the @Block annotation, but that duplicates the information. Is there any way during annotation processing to get the contents of the class/type comment? In this example, I want to get "A nice description of my block" during annotation processing. /** * A nice description of my block **

Best Practice for comments in Java source files?

孤者浪人 提交于 2019-12-05 00:49:01
问题 This doesn't have to be Java, but it's what I'm dealing with. Also, not so much concerned with the methods and details of those, I'm wondering about the overall class file. What are some of the things I really need to have in my comments for a given class file? At my corporation, the only things I really can come up with: Copyright/License A description of what the class does A last modified date? Is there anything else which should be provided? One logical thing I've heard is to keep authors

git commit comment per file

旧巷老猫 提交于 2019-12-05 00:47:51
I am new to git having previously used Perforce, SVN, source safe and many other source control tools. I am looking for the functionality that I used to use in Perforce where I could construct a change list; I was able to add files to the change list and provide a comment specific to each file. git has a staging area into which changed files are added, is there a way to provide a per file comment when adding a file to the staging area? Or perhaps at the comment stage I can add a per file comment; I have had a good look and not been able to workout if either how to perform either - in fact from

Can XML comments go anywhere?

人盡茶涼 提交于 2019-12-04 23:51:59
I wrote a simple tool to generate a DBUnit XML dataset using queries that the user enters. I want to include each query entered in the XML as a comment, but the DBUnit API to generate the XML file doesn't support inserting the comment where I would like it (above the data it generates), so I am resorting to putting the comment with ALL queries either at the top or bottom. So my question: is it valid XML to place it at either location? For example, above the XML Declaration: <!-- Queries used: ... --> <?xml version='1.0' encoding='UTF-8'?> <dataset> ... </dataset> Or below the root node: <?xml

Why are multi-line comments in flex/bison so evasive?

假如想象 提交于 2019-12-04 23:33:57
I'm trying to parse C-style multi-line comments in my flex (.l) file: %s ML_COMMENT %% ... <INITIAL>"/*" BEGIN(ML_COMMENT); <ML_COMMENT>"*/" BEGIN(INITIAL); <ML_COMMENT>[.\n]+ { } I'm not returning any token and my grammar (.y) doesn't address comments in any way. When I run my executable, I get a parse error: $ ./a.out /* abc def Parse error: parse error $ echo "/* foo */" | ./a.out Parse error: parse error (My yyerror function does a printf("Parse error: %s\n"), which is where the first half of the redundant error message comes from). I can see why the second example fails since the entirety

Old Code in comments [closed]

醉酒当歌 提交于 2019-12-04 22:51:35
Closed . This question is opinion-based . It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . Closed 4 years ago . How long should you keep old code commented out in your code base? The contractors continue to keep old code in code base by turning it into comments. This is really frustrating and I want them to just remove the old code instead of commenting it out. Is there a valid reason to keep old code in the code base as comments? I am using Version control by Visual Sourcesafe If you

How can I strip comments and doc strings from python source code? [closed]

为君一笑 提交于 2019-12-04 22:05:32
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . Is there a program which I can run like this: py2py.py < orig.py > smaller.py Where orig.py contains python source code with comments and doc strings, and smaller.py contains identical, runnable source code but without the comments and doc strings? Code which originally looked like this: #/usr/bin/python """Do