[swift-evolution] [Proposal] Swift 2.2: #if swift language version
David Farler
dfarler at apple.com
Fri Dec 18 14:22:08 CST 2015
Hello everyone,
For Swift 2.2, I'd like to add the following build configuration to check for the Swift language version. This is meant to be a short proposal, so let's start with a simple example, compiling with the 2.2 compiler:
#if swift("2.2")
print("Hello")
#else
this code will not parse or emit diagnostics
#endif
The semantics of the build configuration is, "is the Swift language version at least X?". If it is, the active block is parsed and compiled into your program. Like the other build configuration blocks, this isn't line-based, but break on whole statements and declarations. Unlike the other build configurations, however, the inactive block will not parse or emit syntax errors, so you can include syntax for older Swift language revisions in the same file if you prefer.
It sounds like a lot of folks have been wanting something like this, which is why I'm suggesting it for the Swift 2.2 release. I'm curious to hear your feedback!
Best,
David
More information about the swift-evolution
mailing list