Currently, dmd -H generates a "header file" with .di extension containing public symbols of the module being compiled. This enhancement request improves the quality of the output so that these .di files can also serve as a "module contents at-a-glance" overview, in addition to being an importable interface to the module in question.
1) The output should be pretty-printed. Currently, it does try to do this, but the result can be improved further. Perhaps it can format the output using Phobos coding style.
2) Eponymous templates should use the usual shorthand rather than the full form; that is, instead of:
template MyClass(T) {
class MyClass {
...
}
}
it should output:
class MyClass(T) {
...
}
3) It should retain formatting of the input source file where possible. Currently, if the input is:
writeln("This is a very very long string "~
"broken across multiple lines");
then dmd -H would put the entire statement on a single line:
writeln("This is a very very long string " ~ "broken across multiple lines");
It should not do this, since the user presumably has already formatted the source in a more readable way.
3a) Signature constraints should appear on a separate line; that is, instead of:
T myFunc(T,U)(U u) if (is(U : T) && is(typeof(U.front))) {
...
}
the output should be:
T myFunc(T,U)(U u)
if (is(U : T) && is(typeof(U.front)))
{
...
}
which is more readable.
3b) Function attributes should not be reordered. Currently, this code:
void func(int a) pure @safe nothrow {
...
}
gets output as:
pure @safe nothrow func(int a) {
...
}
Instead, the original ordering should be used. Otherwise, it is jarring to read, since one expects the .di file to contain what one wrote, not what the compiler thinks one should have written.
4) Template bodies are currently included inline. This makes the resulting .di file harder to be used as a "module at a glance" overview, since function bodies would be included. This should be enhanced so that the function declarations are grouped together at the top, followed by the implementation bodies, for example, this code:
class MyTemplateClass(T) {
void member1() { /* implementation here */ }
void member2() { /* implementation here */ }
}
should produce this output:
class MyTemplateClass(T) {
// Overview
void member1();
void member2();
// Implementation
void member1() {
/* implementation here */
}
void member2() {
/* implementation here */
}
}
5) Private template members are intermixed with public members; this should be reordered so that public members come first, and private members later.
Comment #1 by k.hara.pg — 2013-10-10T07:39:07Z
(In reply to comment #0)
> 2) Eponymous templates should use the usual shorthand rather than the full
> form; that is, instead of:
>
> template MyClass(T) {
> class MyClass {
> ...
> }
> }
>
> it should output:
>
> class MyClass(T) {
> ...
> }
Partial fix:
https://github.com/D-Programming-Language/dmd/pull/2649
Comment #2 by github-bugzilla — 2013-11-08T00:28:54Z