[DEMO for DIP1005] Converted imports to selective imports in std.array#4963
[DEMO for DIP1005] Converted imports to selective imports in std.array#4963andralex merged 1 commit intodlang:masterfrom
Conversation
|
couldn't that be done with tooling ? (if not with existing traits, at least via instrumenting dmd) |
|
Why not pull it? |
|
@timotheecour it could, but @WalterBright warned the tool would be highly nontrivial. @WalterBright good idea, I'll pull. |
f69b6eb to
e064d56
Compare
|
Auto-merge toggled on |
Just brute-force it. Expand all imports to selective imports of all symbols, then wrap imports in a DustMite comment block and run it through DustMite. We did something similar at DConf 2016 to minimize imports in ddmd. |
|
Which Phobos modules do you want this done on? I could do this in bulk. (After my current reduction finishes.) |
|
@CyberShadow the point of this experiment is to illustrates the steps (and the ongoing maintenance) needed to take advantage of lazy imports, which have not been implemented. As of now, doing this is just giving us more maintenance to do of these lists. |
|
Sorry, I don't get it? Was this PR made to prove some point?
Well... all I'm saying is that it didn't need to be. Is there any practical reason why I shouldn't have a go at replacing module imports with selective imports throughout Phobos? Really shouldn't take much effort, just some setup and CPU time to do the reduction. I'm confused, if this change was not good, then why was it merged? And if it was good, then why shouldn't we have more of it, especially if there's an easy way to do it? |
Yes. The point was to preview the kind of setup that would have all explicit declarations.
Understood, thanks.
The replacement has no value except it adds one extra chore to maintain.
I will undo the PR. |
For the second demo I managed to replace all imports with selective imports in std.array. It was a major effort that involved grepping for heuristics such as "static if", "typeof", "^if", "compiles", "has", "\Wis" etc. A few examples of the difficulties for fun:
isStaticArrayfrom the import list. The error is:This alone took me some 15-20 minutes and almost had me give up.
2, Remove
hasElaborateAssignfrom the import list. The error is:isAssignable. Error message is:isImplicitlyConvertiblewith the result: