Multiple selective imports on one line

ZombineDev via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Dec 23 03:12:22 PST 2015


On Wednesday, 23 December 2015 at 10:51:52 UTC, earthfront wrote:
> I'm using hackerpilot's excellent textadept plugin + DCD, Dfmt, 
> and Dscanner.
> Upon saving files, it produces suggestions, much like warnings 
> from the compiler.
>
> One suggestion is to use selective imports in local scopes. OK, 
> I'll do that.
>
> Now I'm left with a smattering of lines which are just 
> selective imports from a single module:
> void foo()
> {
>   import std.exception:enforce;
>   import std.algorithm:array;
>   import std.algorithm.iteration:filter;
>   import std.functional:memoize;
>
>   //..Work..
> }
>
> What is the proper way to combine these into one line?

Actually array() is from sts.array and correct way to use 
selective imports is:
import std.exception : enforce;
import std.array : array;
import std.algorithm.iteration : filter;
import std.functional : memoize;

If you want to import several symbols from one module, you can 
list them after the column like so:
import std.algorithm : any, find, sort /*, etc... */;


More information about the Digitalmars-d-learn mailing list