On Wednesday, 18 December 2013 at 21:40:08 UTC, Andrei Alexandrescu wrote:
2. Push imports from top level into the entities (functions, classes etc) that use them.

2 comes with its own problems, though. With imports at the top, you can easily tell what the module imports at a glance. Putting imports into the deepest possible scopes where they are used will make it a huge chore to hunt all the imports down. You can of course grep for "import" (or ctrl+f for more plebeian editors), but you still don't have that singular list in one place that you can easily look at to tell what the module imports.

Also, as was mentioned before, some imports (or lack of) will go unnoticed until the particular template or template path that it resides in gets instantiated. I don't relish the idea of thinking that my code is all clear, then getting some missing dependency error down the line after refactoring. This will make code more brittle.

Reply via email to