Multiple selective imports on one line

earthfront via Digitalmars-d-learn digitalmars-d-learn at
Thu Dec 24 01:40:47 PST 2015

On Wednesday, 23 December 2015 at 20:56:39 UTC, Basile B. wrote:
> This is not available in the grammar. You can still open a 
> duplicate enhancement request.
> see also:

OK. I'm putting in my vote for this, and maybe even write up a 
pull request.

The value from this comes when using "component-oriented" 
programming, as touted by AA and WB:

The combination of the good practice of local selective imports, 
and the use of various library functions to perform component 
oriented programming, results in verbose local "import" 

View the example below. The import section is nearly as dense as 
the component oriented block doing the actual work. This is 

void main( string args[] )
   import std.exception: enforce;
   import std.array: array;
   import std.algorithm.iteration: map,filter;
   import std.string: removechars;

//..snip ..//

   auto file = File( args[1] );
   auto result =
     file.byLineCopy(, ',')
     .map!(a => removechars!string( a, "\"" ) )

   writeln("Number of triangle words: ", result);

Understandably, this isn't a huge priority, but a spot for 
improvement none-the-less.

Dennis M. Ritchie's design in his comment seems to be the most 
import {std.array:array; std.algorithm.iteration:map,filter};

More information about the Digitalmars-d-learn mailing list