Bug 11003 – Improve .di generation

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-09T19:07:00Z
Last change time
2015-06-17T21:06:02Z
Keywords
pull
Assigned to
nobody
Creator
hsteoh

Comments

Comment #0 by hsteoh — 2013-09-09T19:07:56Z
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
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/25adf2f8e12ab98a543f8849f774ddea2f3c7756 Partial fix Issue 11003 - Improve .di generation Use shorthand syntax for eponymous function/aggregate templates https://github.com/D-Programming-Language/dmd/commit/03ac3dc04c6db211f732c46a7c1c28016f8820f6 Merge pull request #2649 from 9rnsr/fix11003 Partial fix Issue 11003 - Improve .di generation
Comment #3 by k.hara.pg — 2015-05-04T05:07:45Z
One more case: enum isInt(T) = is(T == int); For that, the generated di still uses old verbose style: template isInt(T) { enum isInt = is(T == int); } --> https://github.com/D-Programming-Language/dmd/pull/4629
Comment #4 by github-bugzilla — 2015-05-06T02:58:54Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c9972ca53bd20362b615834061939094a30c94b8 Partial fix Issue 11003 - Improve .di generation Use shorthand syntax for eponymous variable templates https://github.com/D-Programming-Language/dmd/commit/13d697077bb9c394a69b11fd191c861b1ce6ed71 Merge pull request #4629 from 9rnsr/fix11003 Partial fix Issue 11003 - Improve .di generation
Comment #5 by github-bugzilla — 2015-06-17T21:05:00Z