Swift Wish List
Features I would like to see from Swift and its core ecosystem, to make it a robust and ergonomic language for all use cases.
โ = Unimplemented๐ = Manifestoโพ๏ธ = Pitch๐ = Proposalโ๏ธ = Partially Implemented / Awaiting Implementationโ ๏ธ = In Active Reviewโ = Accepted / Implementedโ๏ธ = Available in Latest Version (5.6)
Language Features
๐ Memory ownership systemโพ๏ธ Variadic generics๐ Flexible memberwise initialization (rationale for initial rejection)
Concurrency
โ๏ธ async
/await
โ๏ธ async let
structured concurrency bindingsโ๏ธ Actorsโ๏ธ Global actorsโ Distributed actors
โ๏ธ async
program entry pointsโ Concurrency in top-level codeโ๏ธ AsyncSequence
โ๏ธ AsyncStream
โ๏ธ Effectful properties (async
andthrows
)
Protocols, Existentials, & Generics
โ Existentials for protocols withSelf
or associated type constraints as new type definitionsโ Lightweight same-type requirements for primary associated types- Enable new primary associated type syntax in more structural positions such as directly on arguments and returns for:
โ Implicitly Opened Existentials, e.g.func isReadyForFinale(_ costume: any Costume) -> Bool
โ Existential types, e.g.func test(_: any Collection<String>)
โ Opaque types, e.g.func evenValues(in: some Collection<Int>) -> some Collection<Int>
- Enable secondary associated types to be constrained directly on arguments and returns for:
โ Existential types, e.g.func test(_: any Collection where Index == Int)
โ Opaque types, e.g.func evenValues(in: some Collection where Index == Int) -> (some Collection where Index == Int)
โ ๏ธ Primary Associated Types in the Standard Libraryโ๏ธ Existential types (any
)โ๏ธ Opaque types (some
)โพ Extend existential types to allow protocol self-conformanceโพ๏ธ Extend metatypes with the newmeta
keywordโ Allowsome
/any
to be used with generic types, e.g.let array: any Array = [1, 2, 3]
โ Allowsome
/any
to be used with class inheritence hierarchies, e.g.let opaqueView: some UIView = MyView()
Strings
โ Regex Typeโ ๏ธ Regex builder DSLโ ๏ธ Regex syntaxโ ๏ธ Regex literals๐ More ergonomic indexing and slicing
Optionals
โ Optional chaining operator (?
) in orthogonal positionsโ if let
with any pattern match, not just optional unwrapsโ Concise syntax for duplicate identifiers inif let
bindings
Domain Specific Languages
โ๏ธ Result buildersโ๏ธ Implicit memberwise initializerโ Result builder protocolโ๏ธ Result builderlet
declarationsโ Stateful result buildersโ Virtualized ASTs (to convert native for-in loops to specialized types, likeSwiftUI.ForEach
)
Metaprogramming & Reflection
โ๏ธ Property wrappersโ More ergonomicCodable
customizationโ First-class macro systemโ Pattern-matching macros, based on the aforementioned regular expression literalsโ Procedural macros- Based on SwiftSyntax and Mirror
- Including its own result builder DSL
- Definable
@Attributes
, so the macro can be applied to various definitions
โพ๏ธ A way to define default protocol implementations as a macro (with the ability to define helper@Attributes
)
โพ๏ธ Dynamic property iteration using key pathsโพ๏ธ Tuple and enum key pathsโ Dependent typesโ Ability to assert that all properties on a type conforming to a protocol must also conform to that protocol (asCodable
does)
Modules
โ Namespacesโพ๏ธ Fully qualified name syntaxโพ๏ธ Formalized@exported
attribute
Interoperability & Platform Support
๐ C++ interoperabilityโ Rust interoperabilityโ COM and WinRT interoperabilityโพ๏ธ Formalized generic external declarations (e.g.@decl
)โ Upstream WebAssembly support
Ecosystem Features
โ Official Swift-only testing libraryโพ๏ธ Formatted command line test outputโพ๏ธ Toolchain managerโ Official HTML documentation generation tool
Standard Library & Foundation
โ New Clock, Instant, and Duration time types for the Standard Libraryโ๏ธ Open source Foundation implementationโ Replace Foundation with modern APIs, split into individually importable submodules
Swift Package Manager
โพ๏ธ Support for scriptingโพ๏ธ Dynamic loading APIโ Package editor commandsโ Official package indexโ Type-safe access to individual resource filesโพ๏ธ Package featuresโ๏ธ Extensible build tools (and additional package plugin APIs)โ๏ธ Package Manager Command Plugins forswift package
โ ExtensibleProduct
types (added as a private API for Swift Playgrounds 4 app projects in Xcode 13.2 beta)โ Package@Attributes
โพ๏ธ Manifest API based on Result Builders