import statement placement
Nicholas Wilson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jun 7 06:17:39 PDT 2017
On Wednesday, 7 June 2017 at 12:39:07 UTC, Russel Winder wrote:
> Are there any idiom rules as to where to put import statements
> in D?
>
> In Python they can go anywhere but PEP-8 suggests they should
> all go at the top of a file, just after the module
> documentation string.
Well for ones that aren't scoped (i.e. used pervasively
throughout the module) I always put them after the module
declaration (if not the file containing main) and doc comment.
For scoped imports they go either on the line after the opening
brace of the enclosing scope, or the line before the
(selectively) imported symbol is used (if there is a reasonable
amount of code preceding the opening brace).
Perhaps the https://dlang.org/dstyle.html imports section should
be expanded.
More information about the Digitalmars-d-learn
mailing list