Swift As Progressive Disclosure
Build APIs and code in the same shape: the common case is a one-liner; the next-most-common case adds one explicit modifier; only the genuinely complex case pulls in the full machinery.…
$ prime install @ios-swift/principle-Swift-as-progressive-disclosure Projection
Always in _index.xml · the agent never has to ask for this.
SwiftAsProgressiveDisclosure [principle] v0.1.0
Swift is designed so that the simple form is the default, and complexity is opted into one feature at a time. A user can write let x = 1 before they know about types; they can write func f() { ... } before they know about access control; they can write a struct before they need a protocol; they can use try before they need typed throws; they can call f() before they need await. Each feature waits until it is actually needed and only then enters the user's code.
Build APIs and code in the same shape: the common case is a one-liner; the next-most-common case adds one explicit modifier; only the genuinely complex case pulls in the full machinery. Default arguments, opt-in attributes (
@MainActor,@Sendable,@escaping), and progressive type erasure (some P,any P) all exist so that a beginner's first use is short and a power user's specialised use is precise. Do not invert this by making the simple case carry decoration it does not need.
Loaded when retrieval picks the atom as adjacent / supporting.
SwiftAsProgressiveDisclosure [principle] v0.1.0
Swift is designed so that the simple form is the default, and complexity is opted into one feature at a time. A user can write let x = 1 before they know about types; they can write func f() { ... } before they know about access control; they can write a struct before they need a protocol; they can use try before they need typed throws; they can call f() before they need await. Each feature waits until it is actually needed and only then enters the user's code.
Build APIs and code in the same shape: the common case is a one-liner; the next-most-common case adds one explicit modifier; only the genuinely complex case pulls in the full machinery. Default arguments, opt-in attributes (
@MainActor,@Sendable,@escaping), and progressive type erasure (some P,any P) all exist so that a beginner's first use is short and a power user's specialised use is precise. Do not invert this by making the simple case carry decoration it does not need.
Applies To
- Default arguments cover the common case; explicit arguments cover variation.
- Generics: start with concrete types or
some P; introduce explicit generics only when client code needs them. - Concurrency: synchronous first;
asyncwhen the operation actually suspends;actorwhen state actually crosses isolation boundaries;@Sendablewhen the closure actually escapes one. - Types:
structbeforeclass;classbeforeactor; protocol composition before generic constraints before associated types. - Error handling: non-throwing first;
throwswhen failure is real; typed throws when callers must distinguish failure modes.
Loaded when retrieval picks the atom as a focal / direct hit.
SwiftAsProgressiveDisclosure [principle] v0.1.0
Swift is designed so that the simple form is the default, and complexity is opted into one feature at a time. A user can write let x = 1 before they know about types; they can write func f() { ... } before they know about access control; they can write a struct before they need a protocol; they can use try before they need typed throws; they can call f() before they need await. Each feature waits until it is actually needed and only then enters the user's code.
Build APIs and code in the same shape: the common case is a one-liner; the next-most-common case adds one explicit modifier; only the genuinely complex case pulls in the full machinery. Default arguments, opt-in attributes (
@MainActor,@Sendable,@escaping), and progressive type erasure (some P,any P) all exist so that a beginner's first use is short and a power user's specialised use is precise. Do not invert this by making the simple case carry decoration it does not need.
Applies To
- Default arguments cover the common case; explicit arguments cover variation.
- Generics: start with concrete types or
some P; introduce explicit generics only when client code needs them. - Concurrency: synchronous first;
asyncwhen the operation actually suspends;actorwhen state actually crosses isolation boundaries;@Sendablewhen the closure actually escapes one. - Types:
structbeforeclass;classbeforeactor; protocol composition before generic constraints before associated types. - Error handling: non-throwing first;
throwswhen failure is real; typed throws when callers must distinguish failure modes.
Source
prime-system/examples/ios-swift/primes/compiled/@ios-swift/principle-Swift-as-progressive-disclosure/atom.yaml