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.
Starter tasks
- SR-5018: Mark
+new
asSWIFT_UNAVAILABLE
when-init
isSWIFT_UNAVAILABLE
. - SR-4949: No error for using
as
patterns with CoreFoundation types
Swift Unwrapped
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.
In a recent episode of the SwiftCoders podcast, Garric Nahapetian interviews Robert Widmann (aka @CodaFi_), a Swift compiler intern and Swift open source contributor.
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.
Amr Aboelela wrote a build-toolchain
script for Android, similar to the existing build-toolchain
script for Darwin. This should be useful for anyone experimenting with Swift on Android.
Ben Cohen added benchmarks for equating/comparing substrings.
Accepted proposals
SE-0179: Swift run
Command was accepted with revisions.
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â.
1) The
--
command syntax.We decided we will not support the:
swift run -- arg1 arg2 arg3
syntax, 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 run
form 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
--chdir
and--in-dir
arguments.We agreed with the feedback that this was confusing, and so decided to:
- Rename the existing
--chdir
argument to--package-path
and 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--chdir
in Swift 4, and remove it at a later date.- Remove the
--in-dir
argument, and instead leave it up to commands themselves to manage interaction with the working directory.- Explicitly specify the behavior of
swift run
to always execute the command in the directory from withswift run
was 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 allowsswift run ...
to integrate with the shell as naturally as possible.Thank you to everyone who participated!
Returned proposals
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. đ
Mailing lists
Dave Abrahams pitched a proposal to overhaul String.Index
. You can find the draft here and the pull request here that implements the changes!
Today
String
shares anIndex
type with itsCharacterView
but not with itsUTF8View
,UTF16View
, orUnicodeScalarView
. This proposal redefinesString.UTF8View.Index
,String.UTF16View.Index
, andString.CharacterView.Index
as typealiases forString.Index
, and exposes a publicencodedOffset
property and initializer that can be used to serialize and deserialize positions in aString
orSubstring
.[âŠ]
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.
Finally
And finally â we cannot be trusted with state.