[swift-evolution] [swift-evolution-announce] [Review] SE-0020 Swift Language Version Build Configuration

David Owens II david at owensd.io
Fri Jan 15 12:49:27 CST 2016

I think the proposal addresses a need that we have with Swift, but I think the proposal introduces yet-another-special case solution.

There is already a construct that nearly serves this purpose. I’d rather see those constructs bolstered and unified.

Previous feedback:

The @available() and if #available constructs are not sufficient as they fall under the same limitations that your proposal addresses: they require that the non-valid branch not be parsed. For example, an API that has changes with a new language feature, such as variadic generic arguments, would not be able to be defined.

If we look at the grammar, I don’t see why the grammar for “availability-argument” couldn’t look like this:

    availability-argument: (platform-name | language-name | package-name) version.

 <>availability-condition → #available­(­availability-arguments <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/availability-arguments>­)­
 <>availability-arguments → availability-argument <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/availability-argument>­  availability-argument <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/availability-argument>­,­availability-arguments <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/availability-arguments>­
 <>availability-argument → platform-name <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/platform-name>­platform-version <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/platform-version>­
 <>availability-argument → *­
 <>platform-name → iOS­  iOSApplicationExtension­
 <>platform-name → OSX­  OSXApplicationExtension­
 <>platform-name → watchOS­
 <>platform-version → decimal-digits <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html#//apple_ref/swift/grammar/decimal-digits>­
 <>platform-version → decimal-digits <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html#//apple_ref/swift/grammar/decimal-digits>­.­decimal-digits <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html#//apple_ref/swift/grammar/decimal-digits>­
 <>platform-version → decimal-digits <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html#//apple_ref/swift/grammar/decimal-digits>­.­decimal-digits <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html#//apple_ref/swift/grammar/decimal-digits>­.­decimal-digits <https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html#//apple_ref/swift/grammar/decimal-digits>­
I’d further argue that the version argument properly adhere to the semver spec: http://semver.org <http://semver.org/>.

The above change, in addition to the change for the if #available (change to: #if available) statement to not parse the unavailable path would seem to provide the solution you want to have in addition to the solution that many package developers could use as well.

The nice thing is that this could be done in stages:

1. Add support for the language condition and change #if available to not parse the non-valid paths
2. Add support for package names
3. Add support for proper semver versioning.

The only breaking change is #1 as the else-clause would no longer parse the code today. When/if semver was supported, the version could still take the decimal digits while adding semver support.


> On Jan 12, 2016, at 10:28 AM, Douglas Gregor <dgregor at apple.com> wrote:
> Hello Swift community,
> The review of SE-0020 "Swift Language Version Build Configuration” begins now and runs through January 17th. The proposal is available here:
> 	https://github.com/apple/swift-evolution/blob/master/proposals/0020-if-swift-version.md <https://github.com/apple/swift-evolution/blob/master/proposals/0020-if-swift-version.md>
> Reviews are an important part of the Swift evolution process. All reviews should be sent to the swift-evolution mailing list at
> 	https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
> or, if you would like to keep your feedback private, directly to the review manager.
> What goes into a review?
> The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine the direction of Swift. When writing your review, here are some questions you might want to answer in your review:
> 	* What is your evaluation of the proposal?
> 	* Is the problem being addressed significant enough to warrant a change to Swift?
> 	* Does this proposal fit well with the feel and direction of Swift?
> 	* If you have you used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
> 	* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
> More information about the Swift evolution process is available at
> 	https://github.com/apple/swift-evolution/blob/master/process.md <https://github.com/apple/swift-evolution/blob/master/process.md>
> Thank you,
> Doug Gregor
> Review Manager
> _______________________________________________
> swift-evolution-announce mailing list
> swift-evolution-announce at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution-announce

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160115/a90fe04b/attachment.html>

More information about the swift-evolution mailing list