<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>Micah Elliott &#187; ocd</title>
	<atom:link href="http://micahelliott.com/tag/ocd/feed/" rel="self" type="application/rss+xml" />
	<link>http://micahelliott.com</link>
	<description>Stories from my Startup Journey</description>
	<lastBuildDate>Mon, 29 Nov 2010 07:46:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
<image>
  <link>http://micahelliott.com</link>
  <url>http://micahelliott.com/mde-gravatar7.png</url>
  <title>Micah Elliott</title>
</image>
	<!-- podcast_generator="podPress/8.8" - maintenance_release="8.8.6.3" -->
	<copyright>Copyright &#38;#xA9; Micah Elliott 2010 </copyright>
	<managingEditor>mde@micahelliott.com (Micah Elliott)</managingEditor>
	<webMaster>mde@micahelliott.com (Micah Elliott)</webMaster>
	<category>posts</category>
	<image>
		<url>http://micahelliott.com/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
		<title>Micah Elliott &#187; ocd</title>
		<link>http://micahelliott.com</link>
		<width>144</width>
		<height>144</height>
	</image>
	<itunes:subtitle></itunes:subtitle>
	<itunes:summary>Stories from my Startup Journey</itunes:summary>
	<itunes:keywords></itunes:keywords>
	<itunes:category text="Society &amp; Culture" />
	<itunes:author>Micah Elliott</itunes:author>
	<itunes:owner>
		<itunes:name>Micah Elliott</itunes:name>
		<itunes:email>mde@micahelliott.com</itunes:email>
	</itunes:owner>
	<itunes:block>no</itunes:block>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://micahelliott.com/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<item>
		<title>Many Types of Code Comments</title>
		<link>http://micahelliott.com/2008/12/many-types-of-code-comments/</link>
		<comments>http://micahelliott.com/2008/12/many-types-of-code-comments/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 07:00:43 +0000</pubDate>
		<dc:creator>Micah</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[checklist]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[ocd]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://micahelliott.com/?p=196</guid>
		<description><![CDATA[It&#8217;s amazing how many different purposes there are for code comments.  Most comments are treated the same by compilers/interpreters &#8212; ignored.  But humans have their own semantics based on some established conventions.  And &#8220;meta-processors&#8221; also do a lot with these; e.g., generating documentation, running tests, executing debug statements, locating tickets, assigning to variables, syntax highlighting [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s amazing how many different purposes there are for code comments.  Most comments are treated the same by compilers/interpreters &#8212; ignored.  But humans have their own semantics based on some established conventions.  And &#8220;meta-processors&#8221; also do a lot with these; e.g., generating documentation, running tests, executing debug statements, locating tickets, assigning to variables, syntax highlighting and checking, compiler diagnostics control, editor folding, hidden full-blown languages, and probably even more.  But the point of this post is to simply enumerate the common comment types.  I&#8217;m working on some syntax highlighting for <a href="http://www.vim.org">Vim</a> to make more semantic sense of these, particularly for Python code.</p>
<p><span id="more-196"></span></p>
<h2>Different Types of Comments</h2>
<p>Of course the code highlighting plugin this blog uses isn&#8217;t able to make much sense of these, but Vim can take it further with a little tweaking.</p>
<pre name="code" class="python"># look out for...
#print 'disabled
##print 'disabled'
for x in xs:  # iterate over xs
### King comment.
###print x
"""Multi-line chunk of commented-out code.  Sometimes only first sentence is significant."""
'''multi-line chunk of docstring'''
"string"
'string'
# TODO: add locking to...
######################################################################
#---------------------------------------------------------------------
# @param foo The metavar that never dies</pre>
<p>I&#8217;ll break these down by line number.</p>
<ol>
<li>is just a traditional comment that exists because something out of the ordinary is happening around the code.</li>
<li>a disabled line of code</li>
<li>another disabled line that is easier for a highlighter to treat.</li>
<li>an end-of-line comment; the most subtle form.</li>
<li>is a descriptive comment marking the purpose of a section of code.</li>
<li>a statement that only executes when in &#8220;debug mode&#8221;.  Perl&#8217;s &#8220;smart comments&#8221; are the only facility I&#8217;m aware of that uses this, but I think they&#8217;re pretty clever.</li>
<li>a formal piece of documentation, usually spanning multiple lines.</li>
<li>a simple way to comment out a large chunk of code.</li>
<li>just a string</li>
<li>same as 7; probably should not be differentiated, but some people prefer to the &#8220;dirk&#8221; version whenever possible.</li>
<li>a codetag (a controversial convention many use to refer to items that should (or do) have tracker tickets associated; described in <a href="http://www.python.org/dev/peps/pep-0350/">PEP 350</a>).</li>
<li>a break in major section of the file.</li>
<li>a minor section break.</li>
<li>a &#8220;javadoc&#8221;-style piece of documentational markup.  Also available with <a href="http://epydoc.sourceforge.net/manual-fields.html#epydoc-fields">Epydoc</a>.</li>
</ol>
<h2>View From Vim</h2>
<p>For a more visual example, here&#8217;s a screenshot showing the best I can make Vim do today.  Featuring the <a href="http://www.vim.org/scripts/script.php?script_id=1365">Adobe color theme</a>, tokenized by <a href="http://www.vim.org/scripts/script.php?script_id=790">python.vim</a>.</p>
<p><img class="aligncenter size-full wp-image-204" title="vim1" src="http://micahelliott.com/wp-content/uploads/2008/12/vim11.png" alt="vim1" width="492" height="523" /></p>
<p>It is certainly within reach to make Vim, emacs, and probably many other editors make use of these semantics in their syntax highlighting.  That color scheme (hacked up for this display) is not (yet) perfect, but it does the job of showing most of the differentiation.  If there are so many purposes for the different comments, shouldn&#8217;t your editor make those differences obvious?</p>
<p>I&#8217;ll offer more details about getting this working, and the value of highly differentiated syntax, and what makes a good color scheme, in a near-future post.</p>
]]></content:encoded>
			<wfw:commentRss>http://micahelliott.com/2008/12/many-types-of-code-comments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

