[swift-evolution] [Proposal] Swift 2.2: #if swift language version
radexpl at gmail.com
Fri Dec 18 14:25:11 CST 2015
Sounds like it could be super useful for libraries!
How about we drop the quote marks, though? If we have `os(iOS)` and `#available(iOS 9, *)` (in other context), why not `swift(2.2)`?
> On 18 Dec 2015, at 21:22, David Farler via swift-evolution <swift-evolution at swift.org> wrote:
> 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")
> this code will not parse or emit diagnostics
> 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!
> swift-evolution mailing list
> swift-evolution at swift.org
More information about the swift-evolution