phobos dependencies

H. S. Teoh hsteoh at quickfur.ath.cx
Sun Jan 5 22:03:20 PST 2014


On Sun, Jan 05, 2014 at 09:22:09PM -0800, Andrei Alexandrescu wrote:
> On 1/5/14 8:44 PM, Kenji Hara wrote:
> >Honestly, "lazy import" (== defer loading module file and running
> >semantic analysis for symbol search) would improve compilation speed
> >for selective imports and static imports, but it would have no merit
> >for basic imports.
> >
> >So precisely, "all imports lazy would be a net large win." is not
> >correct.
> 
> Consider:
> 
> import std.stdio;
> void main() { writeln("Hello, world!"); }
> 
> Currently std.stdio and all modules transitively imported by it
> would be opened.
> 
> With lazy imports, std.stdio gets opened and then writeln() gets
> semantically analyzed. Only modules required by writeln() itself
> will actually be opened. Big difference.
[...]

It would be even better if only those modules required by the specific
instantiation of writeln() being used would be loaded. So if you only
instantiate writeln() with string arguments, then std.format doesn't
even need to be pulled in.

My guess is that this alone would reduce std.stdio template bloat by
about 10-20% or so, possibly more, because most uses of writeln()
actually only need a small part of the entire code that implements it.


T

-- 
Never step over a puddle, always step around it. Chances are that whatever made it is still dripping.


More information about the Digitalmars-d mailing list