What’s better than one issue of Swift Weekly Brief? Two, of course! My apologies for the confusion and bugs with the mailing list this week! Things are back on track now. So enjoy this special Friday edition!
Interested in sponsoring Swift Weekly Brief? Learn more here.
Episode 11: Ownership Manifesto
This week we dive into the Ownership manifesto and give a brief overview of the complex topic of memory ownership revisions currently underway.
News and community
Benjamin Encz wrote an article on implementing an undo/redo stack in Swift using value types as an alternative to
Commits and pull requests
Tony Allevato has opened a pull request to synthesize
Hashable for complex enums and structs. This is the implementation for his yet-to-be-reviewed draft proposal. This would reduce common
Hashable conformance code that developers must routinely write. It’s not clear if this will make it into Swift 4 as the proposal hasn’t even been assigned an SE number.
This proposal has been accepted with revisions. Feedback was strongly positive. Some participants raised concern about the overhead of dynamic checking. The core team shares this concern but feels that there will be adequate opportunities later to make pragmatic decisions about when to enable dynamic checking.
Most of the proposal is accepted. An implementation issue has been discovered with the use of dynamic enforcement on inout parameters. The proposal implementors suggest adopting a stronger rule governing the use of non-escaping closures which will also allow Swift to make firm guarantees about the use of static enforcement when a variable does not escape. The core team tentatively supports this new rule but believes it is a substantial enough revision that it requires a separate review period.
Characterelement type of
Stringis currently a black box that provides little functionality besides comparison, literal construction, and to be used as an argument to
Many operations on
Stringcould be neatly/readably implemented as operations on each character in the string, if
Characterexposed its scalars more directly. Many useful things can be determined by examining the scalars in a grapheme (for example is this an ASCII character?).
The proposal is accepted without revision. The proposal was uncontentious both on swift-evolution and in the Core Team review.
Proposals in review
This proposal is to implement a subset of the changes from the Swift 4 String Manifesto.
- Create a
- Create a
StringProtocolprotocol to allow for generic operations over both types.
- Consolidate on a concise set of C interop methods.
- Revise the transcoding infrastructure.
- Sink Unicode-specific functionality into a
Other existing aspects of
Stringremain unchanged for the purposes of this proposal.
Most of this proposal was previously accepted. An implementation issue has been discovered with the use of dynamic enforcement on inout parameters. The proposal implementors suggest adopting a stronger rule governing the use of non-escaping closures which will also allow Swift to make firm guarantees about the use of static enforcement when a variable does not escape. The core team tentatively supports this new rule but believes it is a substantial enough revision that it requires a separate review period.
The proposal introduces a new
swift runcommand to build and run an executable defined in the current package.
It is common to want to build and run an executable during development. For now, one must first build it and then execute it from the build folder.
To improve the development workflow, the proposal suggests introducing a new first-level
swift runcommand that will build if necessary and then run an executable defined in the
The playground requires Swift 4 (duh!). You need to install the latest Swift 4.0 snapshot from https://swift.org/download/#snapshots and, after installing it, select the toolchain in Xcode.
I plan to keep the playground updated over the summer as more features get implemented.
This is such a great idea and such an easy way to experiment with unreleased versions of Swift.
And finally — Apple Smack Us.