> On Oct 22, 2016, at 2:44 PM, Richard Wei via swift-evolution > <[email protected]> wrote: > > Hi, > > Foundation in 3.0-RELEASE didn't fully resolve the renaming in SE-0086, so we > have `RegularExpression` on Linux and `NSRegularExpression` on macOS. The > naming is now unified in Swift 3.0.1, but there doesn’t seem to be a possible > way to resolve the code breaking change. Consider the example below:
+1. Assuming there are no major objections, I don’t think this needs a full evolution cycle. This seems like a bug fix to me. -Chris > > Currently the following code is only compatible with 3.0-RELEASE, because > RegularExpression on Linux becomes NSRegularExpression in 3.0.1, while we > cannot use `#if` to differentiate between 3.0 and 3.0.1. > > #if !os(macOS) > let regex = try RegularExpression(pattern: pattern, options: [ > .dotMatchesLineSeparators ]) > #else > let regex = try NSRegularExpression(pattern: pattern, options: [ > .dotMatchesLineSeparators ]) > #endif > > Proposed solution: > > If `#if swift(>=)` can take the third version component, we can make the code > compatible with 3.0.1 by the following: > > #if os(macOS) || swift(>=3.0.1) > let regex = try NSRegularExpression(pattern: pattern, options: [ > .dotMatchesLineSeparators ]) > #else > let regex = try RegularExpression(pattern: pattern, options: [ > .dotMatchesLineSeparators ]) > #endif > > Additionally, we can consider supporting the == operator, so that checking > only the version with inconsistent naming is sufficient: > > #if !os(macOS) && swift(==3.0.0) > let regex = try RegularExpression(pattern: pattern, options: [ > .dotMatchesLineSeparators ]) > #else > let regex = try NSRegularExpression(pattern: pattern, options: [ > .dotMatchesLineSeparators ]) > #endif > > Impact on existing code: > > `#if swift(>=X.X.X)` and `#if swift(==X.X.X)` are purely additive. > > -Richard > > _______________________________________________ > swift-evolution mailing list > [email protected] > https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
