Skip to content

Commit ef93be2

Browse files
authored
Update StandardLibraryProgrammersManual.md
1 parent 649b2db commit ef93be2

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

docs/StandardLibraryProgrammersManual.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,31 @@ In this document, "stdlib" refers to the core standard library (`stdlib/public/c
1010

1111
## Coding style
1212

13-
### Source Code Formatting
13+
### Formatting Conventions
1414

1515
The stdlib currently has a hard line length limit of 80 characters. To break long lines, please closely follow the indentation conventions you see in the existing codebase. (FIXME: Describe.)
1616

1717
We use two spaces as the unit of indentation. We don't use tabs.
1818

1919
### Public APIs
2020

21-
All new public API addition to the core Standard Library must go through the [Swift Evolution Process](https://github.com/apple/swift-evolution/blob/master/process.md). The Core Team must have approved the additions by the time we merge them into the stdlib codebase.
21+
#### Core Standard Library
22+
23+
All new public API additions to the core Standard Library must go through the [Swift Evolution Process](https://github.com/apple/swift-evolution/blob/master/process.md). The Core Team must have approved the additions by the time we merge them into the stdlib codebase.
24+
25+
All public APIs should come with documentation comments describing their purpose and behavior. It is highly recommended to use big-oh notation to document any guaranteed performance characteristics. (CPU and/or memory use, number of accesses to some underlying collection, etc.)
2226

2327
Note that implementation details are generally outside the scope of the Swift Evolution -- the stdlib is free to change its internal algorithms, internal APIs and data structures etc. from release to release, as long as the documented API (and ABI) remains intact.
2428

2529
For example, since `hashValue` was always documented to allow changing its return value across different executions of the same program, we were able to switch to randomly seeded hashing in Swift 4.2 without going through the Swift Evolution process. However, the introduction of `hash(into:)` required a formal proposal. (Note though that highly visible behavioral changes like this can be more difficult to implement now that we have a stable ABI -- we can still do them, but in some cases they may require checking the version of the Swift SDK on which the main executable was compiled, to prevent breaking binaries compiled with previous releases.)
2630

27-
We sometimes need to expose some internal APIs as `public` for technical reasons (such as to interoperate with other system frameworks, and/or to enable testing/debugging certain functionality). We use the Leading Underscore Rule (see below) to differentiate these from the documented stdlib API. Underscored APIs aren't considered part of the public API surface, and as such they don't need to follow the Swift Evolution Process. Regular Swift code isn't supposed to directly call these; if necessary, we may change their behavior in incompatible ways or we may even remove them altogether in future releases. Such underscored-but-public API should cou
31+
We sometimes need to expose some internal APIs as `public` for technical reasons (such as to interoperate with other system frameworks, and/or to enable testing/debugging certain functionality). We use the Leading Underscore Rule (see below) to differentiate these from the documented stdlib API. Underscored APIs aren't considered part of the public API surface, and as such they don't need to go through the Swift Evolution Process. Regular Swift code isn't supposed to directly call these; when necessary, we may change their behavior in incompatible ways or we may even remove them. (However, such changes are technically ABI breaking, so they need to be carefully considered against the risk of breaking existing binaries.)
2832

29-
The platform overlays generally have their own API review processes, outside the scope of Swift Evolution.
30-
Anything under `stdlib/private` can be added/removed/changed with the simple approval of a stdlib code owner.
33+
### Overlays and Private Code
3134

32-
All public APIs should come with documentation comments describing their purpose and behavior. It is highly recommended to use big-oh notation to document any guaranteed performance characteristics. (CPU and/or memory use, number of accesses to some underlying collection, etc.)
35+
The platform overlays generally have their own API review processes. These are outside the scope of Swift Evolution.
36+
37+
Anything under `stdlib/private` can be added/removed/changed with the simple approval of a stdlib code owner.
3338

3439
### The Leading Underscore Rule
3540

@@ -61,6 +66,8 @@ extension String {
6166

6267
This makes it trivial to identify the access level of every definition without having to scan the context it appears in.
6368

69+
For historical reasons, the existing codebase generally uses `internal` as the catch-all non-public access level. However, it is okay to use `private`/`fileprivate` when appropriate.
70+
6471
## Internals
6572

6673
#### Unwrapping Optionals

0 commit comments

Comments
 (0)