I disagree that these constructs are similar. #available and @available are inherently runtime queries, whereas checking the version of Swift is a compile-time query. An app ships with code for both branches of "if #available".
On Jan 15, 2016, at 10:49, David Owens II via swift-evolution <firstname.lastname@example.org> wrote:
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.
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.
GRAMMAR OF AN AVAILABILITY CONDITION
availability-condition → #available(availability-arguments)
availability-arguments → availability-argument availability-argument,availability-arguments
availability-argument → platform-nameplatform-version
availability-argument → *
platform-name → iOS iOSApplicationExtension
platform-name → OSX OSXApplicationExtension
platform-name → watchOS
platform-version → decimal-digits
platform-version → decimal-digits.decimal-digits
platform-version → decimal-digits.decimal-digits.decimal-digits
I’d further argue that the version argument properly adhere to the semver spec: 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 <email@example.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:
Reviews are an important part of the Swift evolution process. All reviews should be sent to the swift-evolution mailing list at
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
swift-evolution-announce mailing list
swift-evolution mailing list