[swift-evolution] [swift-build-dev] SE-0151: Package Manager Swift Language Compatibility Version
Rick Ballard
rballard at apple.com
Wed Feb 8 10:55:33 CST 2017
> On Feb 7, 2017, at 11:19 PM, Martin Waitz via swift-build-dev <swift-build-dev at swift.org> wrote:
>
>> The review of SE-0151 “Package Manager Swift Language Compatibility Version" begins now and runs through February 13, 2017. The proposal is available here:
>>
>> https://github.com/apple/swift-evolution/blob/master/proposals/0151-package-manager-swift-language-compatibility-version.md <https://github.com/apple/swift-evolution/blob/master/proposals/0151-package-manager-swift-language-compatibility-version.md>
Thanks for providing feedback, Martin.
When Swift's source compatibility plan defined (https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20161128/029099.html <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20161128/029099.html>), it included the point:
> The Swift Package Manager will allow package authors to specify a list of compatibility modes.
This proposal provides a mechanism to implement that point.
I believe that the reason this was desired is because we expect that package authors may wish to conditionally adopt new Swift 4 language features without breaking their ability to build with Swift 3, using conditional compilation blocks, e.g.
#if swift(>=4.0)
// Swift 4 code goes here
#endif
With this proposal, you can do this by specifying [3, 4], in which case the Swift 4 compiler will compile it as Swift 4 code, and use the code inside the conditional compilation block, while the Swift 3 compiler will also be able to compile it (as Swift 3 code), skipping the conditional compilation block.
If you were only able to specify "3" instead, the Swift 4 compiler would pass `-swift-version 3` when compiling this code, and would skip the conditional compilation block. As such it would not be possible to use any Swift 4 language features unless you set your Swift language compatibility version to "4", at which point it could no longer be built by the Swift 3 compiler.
- Rick
> I’ve one question regarding this proposal:
> Why use the list `swiftLanguageVersions` instead of a simple `swiftLanguageVersion: Int = 3`?
> What’s the advantage of being able to specify `[3,4]`?
>
> If you already have a version 4 compiler, that one will be used anyway and if the source really is compatible with both versions,
> it does not make any difference whether it will be run in version 3 or version 4 mode.
> So just setting it to `3` has the same effect, right?
>
> I think it’s enough to specify something like „this source is intended to be compiled in swift version 3 mode“.
> Most of the time, that’s all you can specify anyway, because you don’t know which future versions happen to be compatible.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170208/8f1b8460/attachment.html>
More information about the swift-evolution
mailing list