On Wednesday, 27 December 2017 at 10:40:38 UTC, RazvanN wrote:
On Tuesday, 26 December 2017 at 15:38:14 UTC, Joakim wrote:
On Tuesday, 26 December 2017 at 13:27:38 UTC, RazvanN wrote:
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:
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.
I doubt that's it, as I noted I was running the standard dmd
main from mars.d. More likely it tries to run asmSemantic on
an asm block in core.atomic and asserts because that
function's stubbed out when there's no backend.
Anyway I am working on this sort of tool also, so maybe we
can unite our efforts.
As in the `depend` import-scoping tool that Andrei wanted
above? If so, that'd be great, as you know the frontend much
better than me. I've been meaning to investigate how to
extract a scope tree from the frontend, as I've never done
much with dmd.
Let me know how far you've gotten and what you want it to do
initially, and maybe I can pitch in with your effort.
Yes, that was the tool I was talking about. I was thinking that
the first
version of the tool just outputs for each import what the used
symbols are;
for example : if you import std.stdio and use 3 symbols from
it, the tool will output "std.stdio: sym1, sym2, sym2" and then
the programmer can update the code accordingly. After
developing this initial version we can think on how to improve
it.
For now, my tool only identifies imported non-templated
functions, but I plan on adding support variables, types etc.
I think I did all this with a dead-simple patch to dmd three
years ago:
http://forum.dlang.org/thread/pbpckzwmfglzgwqve...@forum.dlang.org
I used that tweaked dmd to scope imports for some modules in
phobos last summer:
https://github.com/dlang/phobos/pulls?utf8=✓&q=is%3Apr+author%3Ajoakim-noah+is%3Aclosed+"selective+imports"
That's much better than the alternative of tracking the imported
symbols down yourself, but it's still a pain to edit the files
manually. I'd rather it were integrated with Brian's libdparse
to modify the source for you:
https://github.com/dlang-community/libdparse/
We can chat on slack more about this if you are interested.
I don't use slack or any other chat platform. Probably best to
stick to the forum or github, so that anyone else who's
interested can follow along.