preface

In the 199 issue of Swift weekly, director Kristaps Grinbergs issued an invitation to all readers, which reads as follows:

Everybody is good! I do hope you enjoyed Thanksgiving and were able to spend the holidays with your loved ones. Maybe some of you even played Chandler’s game of naming all 50 states in six minutes.

It’s been a productive time for the Swift team since Thanksgiving, and there’s a lot to talk about today. But before we begin, I want to take this opportunity to say that the next issue will be my last, and maybe the last issue of this project. If anyone is interested in taking over my duties, please let me know. I would love to see the program survive and thrive after I’m gone.

In order to continuously release and update the Swift community weekly, we hope to invite Swift fans to participate in editing the weekly and also invite sponsors to support our platform.

News and Community

Keith Smiley shares information about the Swift 5.5 update and its selection classification process.

John Sundell wrote an article on how to use count and isEmpty to check if a collection contains any elements.

Will Lisac tweeted that the Swift 5.5 Docker image for Raspberry Pi is now available.

Wonderful illustrations by Feli. Her drawings at various conferences are worth seeing.

Max Desiatov announces SwiftWasm 5.5.0 is now available.

Agreed proposal

Se-0328 Structural Opaque result type has been accepted and modified.

During the review, two main areas were discussed: – Optional type spelling. The proposal leaves it as (some P)? , although some P? More succinct, may be used as grammar sugar. The core team is more comfortable with this conservative approach, which can be reconsidered later with more experience with the feature. – When returning the function type f() -> (some P) -> Void, use some in the ‘consume’ rather than ‘produce’ position. Other uses for the some keyword are being discussed, and there are concerns about potential conflicts with some future features. Since using the Opaque Result type at the consumption location is not particularly useful (such functions are not callable in all cases), the core team decided to subset this use and currently only require the Opaque Result type in the return value of the return function type.

A proposal under review

Se-0332: Package manager command plug-in under review.

The SE-0303 introduces the ability to define build tool plug-ins in SwiftPM, allowing custom tools to be automatically invoked during the build process. The proposal extends this plug-in support to allow custom command plug-ins to be defined — plug-ins that users can invoke directly from the SwiftPM CLI or from an IDE that supports Swift packages in order to perform custom actions on their packages.

Se-0331: Removing Sendable from unsafe pointer types is under review for consistency.

Se-0302 introduces the Sendable protocol, including Sendable requirements for various language constructs, consistency of Sendable for various standard library types, and inference rules that non-public types implicitly conform to Sendable.

Experience with Sendable shows that this expression is unnecessarily dangerous and can have unexpected negative effects on implicit consistency.

Se-0333: under review for extended availability withMemoryRebound.

The withMemoryRebound(to: Capacity :_ body:) function performs a closure that temporarily binds a range of memory to a different type than the one bound to the caller. We recommend lifting some significant restrictions on withMemoryRebound and allowing rebinding to a larger set of types, as well as rebinding from raw memory Pointers and buffers.

Note that this proposal runs at the same time as SE-0334, which is also related to unsafe pointer availability.

Se-0334: Pointer availability improvements under review.

The proposal introduces some qualitative improvements to UnsafePointer and its Mutable and Raw variables.

  1. Add an API to get oneUnsafeRawPointerInstance that advances from its starting point to the given alignment.
  2. In a givenUnsafePointer<T>Add the API to get the pointing aggregationTPointer to the storage property.
  3. Adds the ability to compare any two types of Pointers.

Note that this proposal runs at the same time as SE-0333, which is also related to unsafe pointer availability.

Swift BBS

I

Ethan Kusters began discussing support for hosting DocC files in a statically hosted environment.

This article discusses swift-docc and swift-Doc-Render enhancements, which will allow developers to build DocC files that can be hosted without custom routing. This is specifically designed to make DocC usable in other statically hosted environments, most notably GitHub Pages.

This change is intended as a quick solution to urgent needs and provides general benefits. Note, however, that we’ve heard from the community that they want Swift-DOCC to send out static HTML directly, and that this feature is high on the priority list.

II

Sam Deane came up with an idea to implement a default initializable protocol.

Kristaps Grinbergs encountered the factory type situation and eventually came up with a protocol to say “you can construct this type using a default init with no arguments.”

Kristaps Grinbergs found himself surprised at (a) whether this protocol already exists somewhere in the standard library, and (b) whether Swift can automatically make any type conform to it if init() exists.

III

A good reminder that the library Swift Numerics does exist.

Guillaume Lessard has proposed making buffer slicing more useful, especially in the area of partial initialization of buffers.

Subsequences of the UnsafeBufferPointer family have all the Mutable Collection apis of UnsafeBufferPointer, but none of their buffer-specific apis. This makes partial initialization of the buffer and other tasks difficult.

Recommend the blog

LeetCode series

There are five Top 100 high-frequency questions in this series of articles

LeetCode – #1 Sum of two numbers

Difficulty level: easy, the frequency of company interview is as follows:

The company frequency
Amazon U u u u u u
Facebook U u u u u
Airbnb U u u u u
Microsoft U u u u u
LinkedIn U u u u

LeetCode – #2 Add the two numbers

Difficulty level: medium, the frequency of company interview is as follows:

The company frequency
Microsoft U u u u
Amazon End to end
Airbnb End to end

LeetCode – #3 The longest unrepeated substring

Difficulty level: medium, the frequency of company interview is as follows:

The company frequency
Amazon End to end

LeetCode – #4 Finds the middle value of two ordered arrays

Difficulty level: Difficult

LeetCode – #5 finds the longest mirrored string

Difficulty level: medium, the frequency of company interview is as follows:

The company frequency
Amazon End to end

Difficulty level: easy, medium, difficult

Company use frequency: 1 ~ 6 ★

About us

Swift community is a public welfare organization jointly maintained by Swift enthusiasts. We mainly operate wechat public accounts in China. We will share technical content based on Swift practice, SwiftUl and Swift foundation, and also collect excellent learning materials.

Welcome to pay attention to the public number :Swift community, backstage click into the group, you can enter our community’s various exchanges and discussion groups. I hope our Swift community is another common place to belong in cyberspace.

Special thanks to every editor in Swift Community editorial department for their hard work, providing quality content to Swift community and contributing to the development of Swift language, in no particular order:

  • Yu Zhang @Microsoft
  • NiYao @ Trip.com
  • Daiming @ Kuaishou
  • Show @ ESP
  • Du Xinyao @sina

Weekly warehouse: github.com/SwiftCommun… There are many quoted links in the article, so you can click to read the original text more conveniently.