Thread overview
coding standard for D progrimming language
Mar 14, 2013
AngryLemming
Mar 14, 2013
bearophile
Mar 14, 2013
AngryLemming
Mar 14, 2013
Jonathan M Davis
March 14, 2013
Hello everybody.

Do you know any coding standards and code formatting recommendations for D? I want to find something like PEP8 for Python or Code Formatting Guidelines for F# and C#.

With best regards, AngryLemming
March 14, 2013
AngryLemming:

> Do you know any coding standards and code formatting recommendations for D?

http://dlang.org/dstyle.html

Bye,
bearophile
March 14, 2013
On Thursday, 14 March 2013 at 03:43:03 UTC, bearophile wrote:
>
> http://dlang.org/dstyle.html
>
> Bye,
> bearophile

I read this, but this document is very small and without some important question's. For example:

interface ISome ... or interface Some ...

...

int foo() {    or   int foo()
 ...                {
}                       ...
                    }

...

void foo(int a, int b, int c)   or   void foo(int a,
...                                           int b,
                                              int c) ...

etc...

I want to find something like PEP8.
March 14, 2013
On Thursday, March 14, 2013 04:55:14 AngryLemming wrote:
> On Thursday, 14 March 2013 at 03:43:03 UTC, bearophile wrote:
> > http://dlang.org/dstyle.html
> > 
> > Bye,
> > bearophile
> 
> I read this, but this document is very small and without some important question's. For example:
> 
> interface ISome ... or interface Some ...
> 
> ...
> 
> int foo() {    or   int foo()
>   ...                {
> }                       ...
>                      }
> 
> ...
> 
> void foo(int a, int b, int c)   or   void foo(int a,
> ...                                           int b,
>                                                int c) ...
> 
> etc...
> 
> I want to find something like PEP8.

We have no such standard. It's up to you. The closest would be that Phobos uses BSD Allman style braces (i.e. braces go on the same line). Most of what we care about is the naming guidelines, because that affects the API, and those are on the http://dlang.org/dstyle.html page. We quite specifically don't have much in the way of requirements on formatting guidelines. The main rule of thumb is that modules should be consistent, but that says nothing about what the formatting style is, just that it's followed consistently.

- Jonathan M Davis