[swift-evolution] Pre-imported modules (sort of PCH)
vmartinelli at alecrim.com
Mon Jan 25 20:19:49 CST 2016
I've been following the list, but I have not had time to participate more
actively. I must say that I am very happy for what has been discussed, the
more because of what Swift will *not* become than of what it will become.
OK. In Objective-C and other languages we have “.PCH” files or some kind of
“prefix headers”. In Swift we do not have header files (thankfully), but
there is no simple way to “pre-import” modules in a way that all source
files can “see” them without the need of a big list of “imports” at the
beginning of each file, every single time. I know that the “.PCH-like” it
is not a good practice in most cases, but I believe it would be interesting
in some other cases.
Today we have some kind of this functionality when using bridging headers,
but this is in fact a side effect provided by the interoperability with
Objective-C. I am suggesting a pure Swift version of this functionality.
I do not know how we can implement this in Swift, but since we now have the
special case of “Package.swift” to handling SPM things, maybe something
like “Preimport.swift” or “Modules.swift” or something better than these
names (I do not like them…) with the intention of saying: “Hi, compiler!
I'm listing here the modules that are common to the whole project, OK? Can
you take them into account when compiling each project source code file
What do you think?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution