[swift-evolution] [swift-evolution-announce] [Review] SE-0020 Swift Language Version Build Configuration
David Owens II
david at owensd.io
Fri Jan 15 20:47:15 CST 2016
They are similar in that they are trying to restrict codeflow based on external conditions.
Today we have #if os(), #if arch(), plus the ability to set build configuration identifiers. And now there is a new proposal to add #if swift().
Keep the #available() and @available() runtime versions. What I'm saying is add #if available() as a compile-time version and generalize the current uses of the #if usages (these could happen migration steps and don't need to necessarily happen all at once).
When packages start working, it's very easy to see use cases where we want to do the same thing based on package name and version. Build configurations identifiers aren't sufficient for it (version comparison, for instance). So instead needing to propose another construct, #if package(), is there a way to generalize the pattern we are already seeing that could still fit in the scope of this proposal? I think so.
Sent from my iPhone
> On Jan 15, 2016, at 3:35 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> 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 <swift-evolution at swift.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.
>> 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.
>> 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 <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:
>>> 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
>>> Thank you,
>>> Doug Gregor
>>> Review Manager
>>> swift-evolution-announce mailing list
>>> swift-evolution-announce at swift.org
>> swift-evolution mailing list
>> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution