Next: , Previous: , Up: Tips and Standards   [Contents][Index]

C.2 Tips on Writing Comments

Here are the conventions to follow when writing comments.


Comments that start with a single sharp-sign, ‘#’, should all be aligned to the same column on the right of the source code. Such comments usually explain how the code on the same line does its job. In the Emacs mode for Octave, the M-; (indent-for-comment) command automatically inserts such a ‘#’ in the right place, or aligns such a comment if it is already present.


Comments that start with a double sharp-sign, ‘##’, should be aligned to the same level of indentation as the code. Such comments usually describe the purpose of the following lines or the state of the program at that point.

The indentation commands of the Octave mode in Emacs, such as M-; (indent-for-comment) and TAB (octave-indent-line) automatically indent comments according to these conventions, depending on the number of semicolons. See Manipulating Comments in The GNU Emacs Manual.