Lazy private selective imports

Peter Alexander peter.alexander.au at gmail.com
Mon Mar 24 14:18:46 PDT 2014


Would it be possible to perform private selective imports lazily? 
i.e. only import when the symbol selectively imported is 
requested.

--------------------------------------

// not used => std.stdio not imported
import std.stdio : writeln;
void main()

--------------------------------------

// used => std.stdio imported
import std.stdio : writeln;
void main() { writeln("Hello, world"); }

--------------------------------------

// non-selective std.stdio imported
import std.stdio;
void writeln(
void main() {}

--------------------------------------

Are there problems with this?

One semantic difference this would make is that module 
constructors wouldn't be run in the first case whereas they would 
be without this change. Public selective imports would need to be 
done eagerly.

The idea is to reduce code bloat and parse times without having 
to resort to local imports everywhere and hacks like this: 
https://github.com/D-Programming-Language/phobos/pull/2047/files


More information about the Digitalmars-d mailing list