|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: ! 'Issue #94' |
| 4 | +author: modocache |
| 5 | +--- |
| 6 | + |
| 7 | +This week in Swift development: the Swift team created several fun new starter |
| 8 | +tasks, Doug Gregor fixed a nasty bug in Objective-C interop, and the mailing |
| 9 | +lists were abuzz with several exciting Swift Evolution proposals. Adjust your |
| 10 | +Apple Watches -- it's "Swift Weekly Brief O'Clock"! |
| 11 | + |
| 12 | +<!--excerpt--> |
| 13 | + |
| 14 | +{% include sponsor.html %} |
| 15 | + |
| 16 | +### Starter tasks |
| 17 | + |
| 18 | +* [SR-6264](https://bugs.swift.org/browse/SR-6264): This task is to extract |
| 19 | + duplicated code in three methods. The methods each check whether a declaration |
| 20 | + may be used externally based on its access level (`public`, `internal`, etc.). |
| 21 | +* [SR-6272](https://bugs.swift.org/browse/SR-6272): This task is to add better |
| 22 | + diagnostics for common numerical conversions. For example, the Swift compiler |
| 23 | + should be able to suggest a cast for source code that attempts to multiply an |
| 24 | + `Int` and a `CGFloat`. |
| 25 | +* [SR-6312](https://bugs.swift.org/browse/SR-6312): To clone the apple/swift |
| 26 | + family of projects, and to pull in the latest changes to those clones, |
| 27 | + contributors use a Python script: `utils/update-checkout --clone` to clone, |
| 28 | + and just `utils/update-checkout` to update. This task is to modify |
| 29 | + `utils/update-checkout` so that it suggests using `--clone` if the user |
| 30 | + attempts to update before cloning. |
| 31 | + |
| 32 | +If you're looking for a meatier task, you may want to try |
| 33 | +[SR-3423](https://bugs.swift.org/browse/SR-3423), which would allow enum cases |
| 34 | +with tuple raw values. In other words, you could make this possible in Swift: |
| 35 | + |
| 36 | +{% highlight swift %} |
| 37 | +enum Status: (Int, String) { |
| 38 | + case OK = (200, "OK") |
| 39 | + case NotFound = (404, "Not Found") |
| 40 | +} |
| 41 | +{% endhighlight %} |
| 42 | + |
| 43 | +{% include task_remind.html %} |
| 44 | + |
| 45 | +### News and community |
| 46 | + |
| 47 | +[Arek Holko](https://twitter.com/arekholko) [posted](https://github.com/fastred/Optimizing-Swift-Build-Times) |
| 48 | +a checklist for diagnosing and improving long compile times in Swift projects. |
| 49 | + |
| 50 | +[Brian Gesiak](https://twitter.com/modocache) continued his Swift compiler series with |
| 51 | +[*An Introduction to the Swift Compiler Driver*](https://modocache.io/introduction-to-the-swift-compiler-driver). |
| 52 | + |
| 53 | +### Commits and pull requests |
| 54 | + |
| 55 | +[Doug Gregor](https://twitter.com/dgregor79) [fixed](https://github.com/apple/swift/pull/12823) |
| 56 | +an issue in which Swift's ClangImporter would use a stale AST cache for |
| 57 | +properties of Objective-C classes, which affected how declarations would be |
| 58 | +imported into Swift. This most likely fixes an issue in which |
| 59 | +`-[UIView addGestureRecognizer:]` would sometimes be imported as |
| 60 | +`UIView.add(_:)`. |
| 61 | + |
| 62 | +[John McCall](https://twitter.com/pathofshrines) [added](https://github.com/apple/swift/pull/12789) |
| 63 | +a way to represent coroutines in Swift's intermediate language, SIL. |
| 64 | + |
| 65 | +[Daniel Dunbar](https://twitter.com/daniel_dunbar) opened a [pull request](https://github.com/apple/swift-llbuild/pull/195) |
| 66 | +that improves the cancellation model in llbuild. Previously, cancelling a build |
| 67 | +in llbuild would not stop work that was in-flight, but instead merely have those |
| 68 | +units of work finish normally and then report a "cancelled" status. The change |
| 69 | +cancels the work, preventing it from completing as it normally would. |
| 70 | + |
| 71 | +[Mark Lacey](https://github.com/rudkx) opened a [pull request](https://github.com/apple/swift/pull/12682) |
| 72 | +to fix edge cases in which implicitly-unwrapped optional (IUO) usage that was |
| 73 | +disallowed by [SE-0054](https://github.com/apple/swift-evolution/blob/master/proposals/0054-abolish-iuo.md) |
| 74 | +was considered valid in Swift 3 and 4. This is a "source-breaking" change for |
| 75 | +codebases that used syntax that, while being technically invalid in Swift 3 and |
| 76 | +4, would not result in errors being emitted by the Swift compiler until now. |
| 77 | +He also opened a [pull request](https://github.com/apple/swift-corelibs-foundation/pull/1306) |
| 78 | +that removes a soon-to-be-disallowed IUO from swift-corelibs-foundation. |
| 79 | + |
| 80 | +[Philippe Hausler](https://twitter.com/phausler) opened a [pull request](https://github.com/apple/swift-corelibs-foundation/pull/1305) |
| 81 | +to update swift-corelibs-foundation with the latest CoreFoundation source code |
| 82 | +included in macOS High Sierra. |
| 83 | + |
| 84 | +[Francis Ricci](https://github.com/fjricci) opened a [pull request](https://github.com/apple/swift/pull/12702) |
| 85 | +that allows Objective-C to be imported even on non-Darwin platforms. Although |
| 86 | +I would imagine almost no developers use an Objective-C runtime outside of |
| 87 | +Darwin, this does decouple some ClangImporter behavior from its host platform, |
| 88 | +which seems like a good thing to do. |
| 89 | + |
| 90 | +### Proposals in review |
| 91 | + |
| 92 | +The [review](https://lists.swift.org/pipermail/swift-evolution-announce/2017-November/000406.html) |
| 93 | +of _[SE-0187](https://github.com/apple/swift-evolution/blob/master/proposals/0187-introduce-filtermap.md): |
| 94 | +Introduce `Sequence.filterMap(_:)`_ has begun and runs through November 14th, 2017. |
| 95 | + |
| 96 | +> We propose to deprecate the controversial version of a `Sequence.flatMap` |
| 97 | + method and provide the same functionality under a different, and potentially |
| 98 | + more descriptive, name. [...] The name being `filterMap(_:)` as we believe it |
| 99 | + best describes the intent of this function. [...] Since the old function will |
| 100 | + still be available (although deprecated) all the existing code will compile, |
| 101 | + producing a deprecation warning and a fix-it. |
| 102 | + |
| 103 | +The [review](https://lists.swift.org/pipermail/swift-evolution-announce/2017-November/000407.html) |
| 104 | +of _[SE-0188](https://github.com/apple/swift-evolution/blob/master/proposals/0188-stdlib-index-types-hashable.md): |
| 105 | +Make stdlib index types `Hashable`_ begins now and runs through November 14th, 2017. |
| 106 | + |
| 107 | +> This proposal would add `Hashable` conformance to all the index types in the |
| 108 | + standard library. With that done, `[Int]`, `String`, and all other standard |
| 109 | + libary collections would have the same behavior when using subscripts in key |
| 110 | + paths. |
| 111 | + |
| 112 | +### Mailing lists |
| 113 | + |
| 114 | +Tony Parker [solicited](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171106/040959.html) |
| 115 | +public feedback on a Foundation-only proposal that has been evaluated internally |
| 116 | +at Apple. The proposal is for a mechanism to encode and decode JSON keys in |
| 117 | +order to, for example, automatically deserialize `snake_case_keys` as |
| 118 | +`camelCaseKeys`. |
| 119 | + |
| 120 | +[Dave DeLong](https://twitter.com/davedelong) [proposed](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171030/040862.html) |
| 121 | +allowing custom operators to take parameters with default arguments. He also |
| 122 | +provided an implementation with the proposal. |
| 123 | + |
| 124 | +Ben Cohen [pitched](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171106/041053.html) |
| 125 | +eliminating `IndexDistance` from `Collection`. He [tweeted](https://twitter.com/AirspeedSwift/status/928376958357876736) |
| 126 | +that it would make writing generic algorithms easier. |
| 127 | + |
| 128 | +Alejandro Alonso [proposed](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170904/039605.html) |
| 129 | +adding standard library functions for generating random numbers, as well as for |
| 130 | +randomizing the order of an array ("shuffling"). The proposal aims to address |
| 131 | +a pain point in cross-platform Swift development, since different platforms |
| 132 | +use different randomization functions (`arc4random()` on Darwin, `random()` or |
| 133 | +`rand()` on Linux, etc.). |
| 134 | + |
| 135 | +[Jacob Bandes-Storch](https://twitter.com/jtbandes) [re-proposed](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171106/040950.html) |
| 136 | +adding an `allCases` static property to enums. The proposal was widely popular |
| 137 | +when it was first proposed for Swift 3, but ultimately deferred. If it's |
| 138 | +accepted this time, we may see it in Swift 5. |
| 139 | + |
| 140 | +Discussion of [Graydon Hoare](https://twitter.com/graydon_pub)'s Swift Evolution |
| 141 | +[proposal draft](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171023/040652.html), |
| 142 | +which adds a target environment platform condition to the Swift language, |
| 143 | +continues. The patch proposes adding a `#if targetEnvironment(simulator)` |
| 144 | +condition. Replies to the proposal began to discuss what attributes should be |
| 145 | +available as platform conditions. This week, Graydon [pointed out](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171030/040819.html) |
| 146 | +that whether the compilation target was a simulator or not was encoded in the |
| 147 | +target triple, a decision made recently in LLVM, so discussions of whether it |
| 148 | +should be encoded at all should be done on the LLVM mailing lists. |
| 149 | + |
| 150 | +[Brent Royal-Gordon](https://twitter.com/brentdax) [asked](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171030/040863.html) |
| 151 | +about how he could update his once deferred proposal, [SE-0132](https://github.com/apple/swift-evolution/blob/master/proposals/0132-sequence-end-ops.md), |
| 152 | +which proposes renaming several `Sequence` and `Collection` methods such that |
| 153 | +they follow a consistent naming scheme. |
| 154 | + |
| 155 | +Erik Eckstein [proposed](https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20171030/005774.html) |
| 156 | +deprecating the `-Ounchecked` compiler option. This optimization mode removes |
| 157 | +runtime safety checks, and adds additional complexity to the standard library |
| 158 | +code, which must behave differently at that optimization level. |
| 159 | + |
| 160 | +[Rick Ballard](https://twitter.com/rballard) [responded](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171106/040953.html) |
| 161 | +to questions about SwiftPM's roadmap for Swift 5. |
| 162 | + |
| 163 | +Kelvin Ma [pointed out](https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20171106/005811.html) |
| 164 | +that Swift has potential to layout some enums using fewer bytes. |
| 165 | + |
| 166 | +### Finally |
| 167 | + |
| 168 | +Did you [remember](https://twitter.com/lapcatsoftware/status/926911250507993088) to adjust for DST? (That's "delightful Swift time", of course.) |
0 commit comments