Issue #72 01 Jun 2017
Written by: Jesse Squires
We are only a few days away from WWDC 2017! This week the Swift repository saw its 10,000th pull request. Things have been more quiet than usual, but we did get a great update to the WWDC iOS app. 😅 I did not get a ticket, but I will be hanging out in San Jose for most of the week — if you are attending it would be great to meet in person! Aside from WWDC, there are a number of other events happening. For the Swift community, check out Realm’s WWDC Swift Panel and the SwiftCoders meet & greet at AltConf. See you next week!
Interested in sponsoring Swift Weekly Brief? Learn more here.
- SR-5018: Mark
- SR-4949: No error for using
aspatterns with CoreFoundation types
Episode 13: WWDC Predictions
This week, we share our hopes and expectations for the Swift language at WWDC 2017!
News and community
Caleb Davenport highlighted a somewhat undesirable change coming in Swift 4. Due to proposal SE-0110 (but really SE-0029), N-ary tuples are no longer expanded to N arguments in a closure (the “tuple splat behavior”). This means closures will receive a single tuple parameter and you’ll have to expand them manually. Joe Groff noted that this was a source of bad type-checker performance and sympathized about rolling back this syntactic sugar.
Apple have released a free, beginner-level, 900 page book “App Development with Swift” and related teaching materials. In total, it looks like there are 2 books and 5 teacher guides in the series. Hat tip @cocoawithlove.
Thanks to JP Simard for showing me a Swift IDE for macOS called Robotary, which you can use to program LEGO MINDSTORMS EV3 robots. It’s been around for some time and hasn’t been updated since last September, but it looks pretty cool. 😎 Also — lego robots. 😱
Commits and pull requests
Dave Abrahams opened a pull request with his overhaul changes to
String.Index. See the mailing list section below for details on the proposal.
Ben Cohen added benchmarks for equating/comparing substrings.
The proposal has been accepted with revision for Swift 4. There was unanimous support for the proposal in general, but there was discussion on three major points:
- The utility of having both “run – …” and “run command arg1 arg2” forms.
- Whether to build by default.
- The confusion of having two commands which “change the working directory’.
We decided we will not support the:
swift run -- arg1 arg2 arg3syntax, for packages with only one executable, because we felt it was not sufficiently useful versus spelling the command name, and we didn’t want to unnecessarily have two ways to do the same thing. This behavior would be additive if it proved to be worth adding down the road.
We will support the no argument
swift runform in the proposal, since it is unambiguous.
2) Whether to build by default.
This behavior is consistent with our existing behavior for
swift test, and so we believe this is the correct behavior for this proposal.
3) The confusion over the
We agreed with the feedback that this was confusing, and so decided to:
- Rename the existing
--package-pathand change it to simply define the package to work on instead of as a side effect of changing directories. We chose –package-path over –package to leave room for
--package <NAME>syntax in the future, should we have an index. We will make this change and deprecate
--chdirin Swift 4, and remove it at a later date.
- Remove the
--in-dirargument, and instead leave it up to commands themselves to manage interaction with the working directory.
- Explicitly specify the behavior of
swift runto always execute the command in the directory from with
swift runwas run.
In combination, these choices allow
swift run foo ...to generally behave as it would if the package’s products had been built, installed, and run via the shell normally. We believe this allows
swift run ...to integrate with the shell as naturally as possible.
Thank you to everyone who participated!
There was no email on the lists, but SE-0177: Add
clamp(to:) to the stdlib was returned for revision. Given that this hasn’t been communicated to swift-evolution (a review never started in the first place), my guess is that this is simply out-of-scope for Swift 4. That, or everyone is too busy preparing for WWDC. 😅
Indextype with its
CharacterViewbut not with its
UnicodeScalarView. This proposal redefines
String.CharacterView.Indexas typealiases for
String.Index, and exposes a public
encodedOffsetproperty and initializer that can be used to serialize and deserialize positions in a
The result is a great deal of API surface area for apparently little gain in ordinary code, that normally only interchanges indices among views when the positions match up exactly (i.e. when the conversion is going to succeed). Also, the resulting code is needlessly awkward.
And finally — we cannot be trusted with state.