The last two weeks have brought us some exciting progress on Swift 5 and Xcode 9.3 (which brings us Swift 4.1). Regarding Xcode, we’re now on beta 3.
We can also expected some news on WWDC soon - last year, Apple announced WWDC on February 16th.
That being said, I don’t want to distract you from all the topics discussed in the newsletter. Thanks for reading!
News and community
Ted Kremenek announced that Swift will participate in Google Summer of Code this year!
With Xcode 9.3 beta 3 came a new tool for parsing code coverage output,
Erik Eckstein wrote a blog post on the official Swift.org blog on a new code size optimization mode in Swift 4.1. If you are already testing projects in Xcode 9.3, feel free to give this a try!
Joe Groff wrote a blog post on optimizing global constant data structures.
Ben Cohen gave a talk on “Extending the Standard Library”.
Dave DeLong wrote a blog post about how he’d want to change how Swift deals with protocols.
Commits and pull requests
Takeru Chuganji merged a pull request with an improvement to Swift diagnostics, offering fix-its to insert numeric conversions when needed.
On February 8 2018, the Core Team decided to accept this proposal.
After reviewing the feedback from the community, the Core Team felt the spelling of the attribute should remain as proposed —
@dynamicMemberLookup. The alternative of
@dynamic(...)was also considered, but the Core Team felt that spelling to be too close to the dynamic keyword and a potential source of confusion.
The rationale for the marker being an attribute instead of a protocol (as in the original proposal) was well-articulated by Chris Lattner in the review thread in that the marker protocol would not provide the expected affordances of a normal protocol.
Proposals in review
Boolvariables, it is common to want to toggle the state of the variable. In larger (nested) structs, the duplication involved can become especially annoying:
It’s also easy to make a mistake in the code above if there are multiple
Boolvars. [The proposed solution is to] add a method toggle on
This allows us to write the example above without duplication:
With the addition of conditional conformances to the language, the result of
zip(_:_:)can now be a
Collectionif both containers being zipped conform to
Collectionas proposed, expressions such as the following do not take advantage of zip’s conditional conformance.
The result of this expression only conforms to
Sequenceand as such provides none of the
This proposal adds a combined
Dictionary, as a companion to the
filtermethods introduced by SE-0165. The new
compactMapValuesoperation corresponds to
We sometimes need to transform and filter values of a
Dictionaryat the same time, and
Dictionarydoes not currently provide an operation that directly supports this.
I propose to replace the
OpaquePointerstruct with a deprecated typealias for
UnsafeRawPointer. Then, change the import of C pointers-to-incomplete-types to produce
UnsafeRawPointer, depending on whether the pointee
Doug also pitched eliminating
I propose to completely eliminate the
NSObjectProtocol) from Swift, leaving only a deprecated typealias (to
AnyObject) as a backward-compatibility shim.
Dave DeLong pitched a proposal to add a
This would make it much easier to capture the context in which some code is executed rather than having to put
file: StaticString = #file, line: UInt = #lineparameters everywhere. A
context: Context = #contextwould be much easier.
Using collection indexes are a bit of a bother when you want to do simple slicing and a type is not indexed by
For a simple example take the code here:
The intent of advancing
startIndexgets a bit muddled.
So to ease this I think we could add
Making the example above:
This proposal introduces the ability to rely on a dependency statically (meaning that it will be available for import in your
Package.swiftfile). The idea is that this will greatly increase the usability and customization of the
The API does not work as expected? Can’t be. Its unit tested and all. Did you read its documentation?