Cool project idea: organise/remove imports
Vladimir Panteleev
thecybershadow.lists at gmail.com
Fri Jul 12 09:37:46 UTC 2024
On Thursday, 11 July 2024 at 10:28:35 UTC, Atila Neves wrote:
> It'd be amazing if one could hit a key/key combination and have
> all imports pared down to the absolute minimum (and made
> local). If only I had the time...
I made this a while ago. It's not quite what you describe -
instead of typing `import std;`, you don't type any imports at
all, and instead the tool uses compiler error messages + `.json`
output to add missing imports.
https://forum.dlang.org/post/baayfburkivhwurpepav@forum.dlang.org
Code is here: https://github.com/CyberShadow/AutoFix (now
includes an Emacs package).
I'm not sure that local imports are best for all cases. They're
good for trivial things like pure parsing functions wanting to
import some utility module. Otherwise, having them at the top of
the module is a good way to document and understand the
relationships of the module with other parts of the program - for
instance, networking imports tell you right away that it talks to
other things on the network, filesystem imports tells you it uses
files, same with custom subsystems.
More information about the Digitalmars-d
mailing list