|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: ! 'Issue #152' |
| 4 | +author: btb |
| 5 | +sponsor: |
| 6 | + link: TODO |
| 7 | + heading: TODO |
| 8 | + body: TODO |
| 9 | + displaylink: TODO |
| 10 | +--- |
| 11 | + |
| 12 | +> TODO: intro comments |
| 13 | +
|
| 14 | +<!--excerpt--> |
| 15 | + |
| 16 | +{% include sponsor.html %} |
| 17 | + |
| 18 | +### Starter tasks |
| 19 | + |
| 20 | +> TODO |
| 21 | +
|
| 22 | +### Podcasts |
| 23 | + |
| 24 | +> TODO: Latest episode(s) of Swift Unwrapped & the Swift Community Podcast |
| 25 | +
|
| 26 | +### News and community |
| 27 | + |
| 28 | +[Ted Kremenek](https://twitter.com/tkremenek) shared [an update](https://forums.swift.org/t/on-the-road-to-swift-6/32862) |
| 29 | +on the road to Swift 6, with many interesting insights. If there's one thing |
| 30 | +you're going to pick up from this issue, it should be this — it's a great read. |
| 31 | +Some things mentioned: |
| 32 | + |
| 33 | +- Faster builds |
| 34 | +- More informative and accurate diagnostics |
| 35 | +- Reliable and fluid debugging experience |
| 36 | +- Provide excellent solutions for major language features such as memory |
| 37 | +ownership and concurrency |
| 38 | +- Significantly improve the performance of incremental builds |
| 39 | +- Improve code completion performance, reliability, and experience |
| 40 | + |
| 41 | +Like I said; you're going to want to give this a read. |
| 42 | + |
| 43 | +[JP Simard](https://twitter.com/simjp) created a poll [about the oldest Swift version people are actively using](https://twitter.com/simjp/status/1218613429881040897); |
| 44 | +a quite surprisingly high amount (to me) is pretty up-to-date with the latest |
| 45 | +Swift versions! |
| 46 | + |
| 47 | +[George Barnett](https://twitter.com/glbrntt) released [SwiftNIO 2.13.0](https://github.com/apple/swift-nio/releases/tag/2.13.0). |
| 48 | + |
| 49 | +### Commits and pull requests |
| 50 | + |
| 51 | +[Pavel Yaskevich](https://twitter.com/pyaskevich) merged [a pull request](https://github.com/apple/swift/pull/28837) |
| 52 | +that is a big step toward improving type inference for closures over time. |
| 53 | + |
| 54 | +### Accepted proposals |
| 55 | + |
| 56 | +> TODO |
| 57 | +
|
| 58 | +### Returned proposals |
| 59 | + |
| 60 | +> TODO |
| 61 | +
|
| 62 | +### Rejected proposals |
| 63 | + |
| 64 | +> TODO |
| 65 | +
|
| 66 | +### Proposals in review |
| 67 | + |
| 68 | +[SE-0270](https://github.com/apple/swift-evolution/blob/master/proposals/0270-rangeset-and-collection-operations.md): *Add Collection Operations on Noncontiguous Elements* is [under a third review](https://forums.swift.org/t/se-0270-review-3-add-collection-operations-on-noncontiguous-elements/32839). |
| 69 | + |
| 70 | +> We can use a `Range<Index>` to refer to a group of consecutive positions in a |
| 71 | +collection, but the standard library doesn't currently provide a way to refer |
| 72 | +to discontiguous positions in an arbitrary collection. I propose the addition |
| 73 | +of a `RangeSet` type that can represent any number of positions, along with |
| 74 | +collection algorithms that operate on those positions. |
| 75 | +> |
| 76 | +> There are varied uses for tracking multiple elements in a collection, such as |
| 77 | +maintaining the selection in a list of items, or refining a filter or search |
| 78 | +result set after getting more input from a user. |
| 79 | +> |
| 80 | +> The Foundation data type most suited for this purpose, `IndexSet`, uses |
| 81 | +integers only, which limits its usefulness to arrays and other random-access |
| 82 | +collection types. The standard library is missing a collection that can |
| 83 | +efficiently store ranges of indices, and is missing the operations that you |
| 84 | +might want to perform with such a collection. These operations themselves can |
| 85 | +be challenging to implement correctly, and have performance traps as well — see |
| 86 | +last year's [Embracing Algorithms](https://developer.apple.com/videos/wwdc/2018/?id=223) |
| 87 | +WWDC talk for a demonstration. |
| 88 | + |
| 89 | +### Swift Forums |
| 90 | + |
| 91 | +[Frederick Kellison-Linn](https://twitter.com/jumhyn) pitched [a proposal](https://forums.swift.org/t/allow-chained-member-references-in-implicit-member-expressions/32829) |
| 92 | +to allow chained member references in implicit member expressions. |
| 93 | + |
| 94 | +> I propose that we extend implicit member syntax (a.k.a. "leading dot syntax") |
| 95 | +to allow for chained member references rather than just a single level. |
| 96 | +> |
| 97 | +> When the type of an expression is implied by the context, Swift allows |
| 98 | +developers to use what is formally referred to as an "implicit member |
| 99 | +expression", sometimes referred to as "leading dot syntax": |
| 100 | + |
| 101 | +```swift |
| 102 | +class C { |
| 103 | + static let zero = C(0) |
| 104 | + var x: Int |
| 105 | + |
| 106 | + init(_ x: Int) { |
| 107 | + self.x = x |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +func f(_ c: C) { |
| 112 | + print(c.x) |
| 113 | +} |
| 114 | + |
| 115 | +f(.zero) // prints '0' |
| 116 | +``` |
| 117 | + |
| 118 | +> However, attempting to use this with a chain of member references fails: |
| 119 | +
|
| 120 | +```swift |
| 121 | +extension C { |
| 122 | + var incremented: C { |
| 123 | + return C(self.x + 1) |
| 124 | + } |
| 125 | +} |
| 126 | + |
| 127 | +f(.zero.incremented) // Error: Type of expression is ambiguous without more context |
| 128 | +``` |
| 129 | + |
| 130 | +> On master, the new diagnostic system has improved the produced error: |
| 131 | +
|
| 132 | +```swift |
| 133 | +f(.zero.incremented) // Error: Cannot infer contextual base in reference to member 'zero' |
| 134 | +``` |
| 135 | + |
| 136 | +> but the same problem persists. |
| 137 | +
|
| 138 | +### Finally |
| 139 | + |
| 140 | +[#nofilter](https://twitter.com/jckarter/status/1217861938136276993). |
0 commit comments