[swift-evolution] Module importation at project scope

Brent Royal-Gordon brent at architechies.com
Mon Feb 8 16:30:06 CST 2016

> #import (project scope import)
> https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160125/008461.html
> Pre-imported modules (sort of PCH)
> https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160125/007706.html
> In many languages, including Swift, when we are developing apps (frameworks are other history), we have to include/import dozens of libraries references. The proposal is to have for app projects (maybe not for frameworks projects) a way to say to Swift compiler that we are using some module everywhere in the project code files, so we can expect the module to be always available without a `import` on the top of each file.

Swift seems to generally have a philosophy where the interpretation of a file shouldn't depend on global context, like compiler error switches. It seems to me that these features would violate that rule.

In particular, it's worth keeping in mind that the actual purpose of a PCH is not to reduce the number of imports in the text of each C file, but to precompile large, widely-included headers once so they don't need to be compiled separately for every file. That's the "PC" in "PCH". Using a PCH to reduce boilerplate is actually abusing the mechanism.

Brent Royal-Gordon

More information about the swift-evolution mailing list