Difference between revisions of "Phobos coding conventions"

From D Wiki
Jump to: navigation, search
(stub)
 
(copy edit)
Line 3: Line 3:
 
* Avoid using the tab character.
 
* Avoid using the tab character.
 
* Use 4-space indentation.
 
* Use 4-space indentation.
* For blocks enclosed by curly braces ({}), the opening brace should be on its own line, at the same indentation level as its containing block:
+
* For blocks enclosed by curly braces ({}), the opening and closing braces should be on their own lines, at the same indentation level as its containing block:
 
<syntaxhighlight lang="d">
 
<syntaxhighlight lang="d">
 
void main(string[] args)
 
void main(string[] args)
Line 17: Line 17:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
* Identifiers should use camelcase instead of underscores: myVariable instead of my_variable.
 +
 +
In general, just like in any collaborative project, try your best to conform to the same coding style as in the rest of the source file you're editing.

Revision as of 23:42, 10 December 2012

If you're planning to submit pull requests for druntime or Phobos, you should follow the following coding conventions:

  • Avoid using the tab character.
  • Use 4-space indentation.
  • For blocks enclosed by curly braces ({}), the opening and closing braces should be on their own lines, at the same indentation level as its containing block:
void main(string[] args)
{
    if (args.length == 0)
    {
        writeln("Please specify filename");
    }
    else
    {
        lotsOfDotDotDotMagic(args);
    }
}
  • Identifiers should use camelcase instead of underscores: myVariable instead of my_variable.

In general, just like in any collaborative project, try your best to conform to the same coding style as in the rest of the source file you're editing.