Daniel Duan

[Accepted with Modifications] SE-0225

This announcement comes with some answers to “what should be in the Swift standard library?”


Almost all library features can be composed from existing features with enough effort. To be considered for addition to the library, a proposed feature must satisfy two conditions: it must provide functionality that is useful to a substantial population of Swift programmers, and it must provide substantial advantages over the alternative ways of accomplishing that functionality. Potential advantages include:

It may be complex, challenging, or error-prone for users to implement themselves. It may have substantial performance advantages over a user implementation, either because it has access to library internals or just because the library implementation will likely be more carefully tuned. It may be substantially easier to work with because it composes better with other language or library features. It may be substantially more “fluent”: that is, more natural to discover, use, and read in code. The implementation may involve composing primitives in a subtle or tricky way, or the primitives may be unfamiliar to many programmers. This is a more subjective criterion than the others, and people may reasonably differ about how to apply it. For example, consider adding an method to rotate the elements of an array. This operation can be performed using a relatively simple composition of slicing and concatenation:

array = array[amount...] + array[..<amount]

However, a method to rotate an array in-place would still be welcome: it would have substantial performance advantages, it would avoid several potential off-by-one errors, and it would be significantly easier for a reader to recognize as a rotation.

In contrast, a property like isNotEmpty offers no substantial advantages over !isEmpty, and adding it would open the door to adding trivial negations of essentially every predicate.