Programming notes: Difference between revisions
Jump to navigation
Jump to search
(Created page with "This is a collection of recommendations on programming style. <ol> === Notes on C === <li>For symmetry reasons, I dislike this layout: <pre> if (x==2){ x++; ...") |
m (→Notes on C) |
||
Line 7: | Line 7: | ||
<li>For symmetry reasons, I dislike this layout: |
<li>For symmetry reasons, I dislike this layout: |
||
<pre> |
<pre> |
||
if (x==2){ |
|||
x++; |
x++; |
||
} |
|||
} |
|||
</pre> |
</pre> |
||
Far cleaner is this: |
Far cleaner is this: |
||
<pre> |
<pre> |
||
if (x==2) |
|||
{ |
|||
{ |
|||
x++; |
x++; |
||
} |
|||
} |
|||
</pre> |
</pre> |
||
</li> |
</li> |
Revision as of 13:44, 25 June 2014
This is a collection of recommendations on programming style.
- For symmetry reasons, I dislike this layout:
if (x==2){ x++; }
Far cleaner is this:
if (x==2) { x++; }
- For clarity, I prefer indentations to be 8 spaces (not 4). If you follow this, you'll be in good company. Insert the following snippet in your ~/.emacs file:
(defconst my-c-style '((c-basic-offset . 8) (c-offsets-alist . ((substatement-open . 0) ) ) ) "C Style") (defun my-c-mode-common-hook () (c-add-style "personal" my-c-style t) (setq fill-column 135) ) (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)