On Thursday, 21 December 2017 at 03:31:16 UTC, Joakim wrote:
On Wednesday, 20 December 2017 at 18:21:33 UTC, Andrei
Alexandrescu wrote:
On 12/15/2017 02:10 PM, Seb wrote:
[...]
Dmitry wrote a nice PR for that, and I wrote two:
https://github.com/dlang/phobos/pull/5942
https://github.com/dlang/phobos/pull/5931
https://github.com/dlang/phobos/pull/5948
My approach has been the following:
* First I tried to clarify which module imports what by means
of replacing "import std.xxx;" with "import std.xxx : yyy,
zzz, ...;" That has been of tremendous help in assessing each
module's dependency liability.
* Then I tried to figure which imports are most costly. I
inserted __EOF__ in the module at different parts and measure
how long it takes to just import that module. After a few
attempts it becomes clear which imports are heaviest.
* Then I pushed those heavy imports down where they're needed.
An import placed in a function will not be opened while that
function's module gets imported. Same goes about template
types, but not structs or classes. (That should be fixed; see
Seb's comment in my last PR.)
Not only such work reduces import times, but it's illuminating
for maintenance because it represents dependencies in a
simple, fine-grained matter.
A tool (call it depend - heh) to automate that would be
awesome. For example, this run would make all imported names
explicit:
depend --explicit *.d
This run would push all imports down to the innermost scope of
usage:
depend --pushdown *.d
Andrei
I'm on it. I tried using a version of Seb's frontend library
yesterday but with the standard dmd main and tried running it
on std.stdio, but it asserted in asmSemantic because of an asm
block somewhere in druntime, so I'm back to using a tweaked
full dmd with the backend simply disabled again:
I ran into the same issue. The problem was that currently the
frontend
doesn't set the version identifiers. There's a PR which tries to
fix it [1],
but if you want to go back at using the compiler library via
Seb's interface
you just have to call this method [2] in the initialization step.
Anyway I am working on this sort of tool also, so maybe we can
unite our efforts.
Ping me if you wish so,
[1] https://github.com/dlang/dmd/pull/7524
[2] https://github.com/dlang/dmd/blob/master/src/dmd/mars.d#L1314
https://github.com/dlang/dmd/pull/7425
https://github.com/dlang/dmd/blob/master/src/dmd/gluelayer.d#L47
https://gist.github.com/joakim-noah/09cf49bee3d82b03a54f
Once I have something basic working, I'll put it up on github,
so others who are interested can play with it and pitch in to
make it a real tool.
Best regards,
RazvanN