[Issue 11003] New: Improve .di generation
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 9 19:07:58 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11003
Summary: Improve .di generation
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: hsteoh at quickfur.ath.cx
--- Comment #0 from hsteoh at quickfur.ath.cx 2013-09-09 19:07:56 PDT ---
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.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list