Whatever guidance is outdated and should no longer exist. I donโt believe that there is any D-style guide that is considered valid, and I donโt think that Walter Bright, Andrei Alexandrescu, etc. They want him to be like that. Also, as far as I remember, in C ++ Standards Code: 101 Rules, Recommendations and Recommendations , Herb Sutter and Andrei said that style guides are a bad idea (or at least they were really specific), but I would have to pull out a book to say exactly what they said. Therefore, I rather doubt that Phobos (who is headed by Andrey) will have some kind of leadership style; Of course I donโt know anything. There might be some recommendations for formatting the code that comes with Phobos (for example, to make your code look like the rest of the module or something similar), but someone like Andrei or one of the other Phobos developers will have to answer this . Of course, with about 15 different developers working on Phobos, you will definitely get several different styles in your code if there is no forced style guide.
So, I don't think that there really is any recommended coding style for D or Phobos. As far as I understand, the main people behind D do not particularly relate to the style guide, and they certainly did not push one. So now, in fact, there is not one, and I do not expect that in the future there will be one.
EDIT: Well, I went and looked exactly what Herb Sutter and Anderi Alexandrescu said in C ++. Coding Standards: 101 Rules, Guidelines and Best Practices . Itโs not entirely that they are against coding standards to the extent that they contradict particularly restrictive ones that provide personal tastes or outdated practices. I am not going to bring all this here (this is a good book, and you should raise it anyway), but here are some key points.
- Do not indicate how much indentation, but indent to show the structure.
- Do not apply a specific line length, but keep the line length readable.
- Do not rewrite the names, but agree with them.
- Do not predefine comment styles (unless the tools extract specific styles into the documentation), but write useful comments.
Some examples they gave were that
- The placement of the brackets should not matter, but it should be consistent and readable.
- In tabbed spaces, they don't seem to care about what the coding standard says about this.
- They are against the Hungarian notation in C ++, but believe that it can be useful in languages โโthat are less safe for the language.
- They are completely opposed to the fact that there is one return statement in the function.
Despite this, they believe that formatting should be consistent in the source file. Obviously, Phobos does not necessarily adhere to this at the moment, but Andrei simply raised some of the conventions that were usually held in the newsgroup and looked, perhaps, at the execution of some of them (the actual entry is archived here ).
However, while Phobos is open source and anyone is free to submit patches, remember that this is an API intended for public consumption. Only Phobos developers should look at the code (at least if the documents are properly completed) - of course, they are the only ones who will work on it directly - so there is no need for a public coding standard, even if they use them. It looks like they can use more consistency and that they can work on it, but everything that is going to be done for third parties makes it more readable. No one else should know what the standard really is (although if you looked at enough code following the standard, you could find at least more or less what the standard said).
As for D in general, there are certain conventions that are considered good practice (for example, usually using auto instead of specifying a type, if you really shouldn't specify a type), but just like in C ++, you can code with any desired coding style, and D developers are not dictatorial enough to try to apply the style to the entire D community.