SE-0212 — Compiler Version Directive

The review of SE-0212 — Compiler Version Directive begins now and runs through May 7, 2018.

The proposal is available here:

https://github.com/apple/swift-evolution/blob/master/proposals/0212-compiler-version-directive.md

Reviews are an important part of the Swift evolution process. All review feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to the review manager (via email or direct message in the Swift forums).

What goes into a review of a proposal?

The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine the direction of Swift.

When reviewing a proposal, here are some questions to consider:

  • 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 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?

Thanks,

Ted Kremenek
Review Manager

2 Likes

I see the theoretical benefit of this new directive. Since it's purely additive, it seems like a reasonable addition.

Is there any specific example that's been cited where this would be useful in practice (perhaps from the pitch thread)? I can't think of any real-world use case where I'd need to know more than just the swift version.

Here's a an example from the wild (PromiseKit):

https://github.com/mxcl/PromiseKit/blob/master/Sources/when.swift#L173

that could be simplified to:

#if compiler(>=4.2)

And those conditionals will continue to grow more complicate as more language compatibility modes are introduced.

2 Likes

+1 to this proposal.


I think there's a typo worth mentioning;

It creates an exponential growth in the number of Swift versions for each new compatibility version.

I'm pretty sure it's quadratic, not exponential. Let N be the number of Swift versions available for compatibility. N is roughly equivalent to the numbers of compiler versions provided. Then, we have:

  • For each compiler version i:
    • For each available language version j <= i:
      Implement compatibility for version j.

Since both loops are bounded by N in size, you have O(N^2) implementations being supported across all compiler versions being provided.

1 Like

You're correct. I've made the change (and fixed other typos) in the proposal.

1 Like

I'm in favor of this but as belatedly noted in the pitch thread we still need to use "4.1.50" (or similar) as the language version for -swift-version 4 in the Swift 4.2 compiler…so that 4.1 compilers can distinguish between Swift 4.1.x and Swift 4.2-in-4-mode! If you need to be compatible with a 4.0 or 4.1 compiler, you have to keep using #if swift a little longer.

@hartbit : Can you incorporate this revision into the proposal? Otherwise, the proposal is going to be accepted as is.

Proposal Accepted

SE-0212 has been accepted, with the following minor amendment mentioned by @jrose:

Thanks for everyone who participated in this review!