Difference between revisions of "Order of import statements"
(order of import statements) |
m (Category:Proposals) |
||
Line 23: | Line 23: | ||
public import mylib.goodstuff.garbage; | public import mylib.goodstuff.garbage; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | <noinclude> | ||
+ | [[Category:Proposals]] | ||
+ | </noinclude> |
Latest revision as of 09:17, 25 June 2018
Order of Import Statements
As an aid to maintainability, discoverability and possible automation, it would be helpful to have a simple import ordering convention? Specifically:
- imports from std come first. Root-level comes first, followed by in alphabetical order for sub-levels
- an empty line comes next
- imports from third-party come next. Root-level comes first, followed by in alphabetical order for sub-levels
- an empty line comes next
- imports from other modules in "this" organisation/project/library come last. Root-level comes first, followed by in alphabetical order for sub-levels
An example:
import std.loader;
import std.utf;
import std.c.windows.windows;
import mango.blah;
import mango.stuff;
import mango.abc.otherstuff;
import mango.things.nicethings;
public import mylib.stuff
public import mylib.badthings.hmm;
public import mylib.goodstuff.garbage;