Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify all imports to only selectively import the symbols used #10

Closed
joakim-noah opened this issue Oct 28, 2014 · 4 comments
Closed

Modify all imports to only selectively import the symbols used #10

joakim-noah opened this issue Oct 28, 2014 · 4 comments

Comments

@joakim-noah
Copy link

Anyone could develop using the standard import statements that import all public symbols from a module, and then run dfix over the source and have the imports modified to only specify the symbols actually pulled in. This is useful for those reading the source later because it's easy to tell exactly what was imported and from where, without having to go searching for which module it came from.

Another optimization would be to move the import inside a function if it's the only function that uses the import, ie scoped imports, which is already starting to be done in pieces in druntime/phobos. Of course, you could also chuck imports that are unused, which you've talked about listing with Dscanner before.

D provides a lot of power with these selective and scoped import constructs, but it's not easy to develop using them. Also, this feature added to dfix could go a long way towards untangling phobos.

@Hackerpilot
Copy link
Collaborator

This is not at all trivial to implement.

@MartinNowak
Copy link
Contributor

No it's not, how about starting with a slightly simpler milestone, warning about unused imports.

@Hackerpilot
Copy link
Collaborator

@Hackerpilot
Copy link
Collaborator

There is no correct way to implement this without implementing a compiler front-end. I'm going to close this because I'm not going to work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants