Skip to content

Commit 910b4ee

Browse files
authored
Merge pull request swiftlang#39398 from apple/document-new-availability-guidelines
[stdlib][doc] Update stdlib manual to reflect new availability guidelines
2 parents 12b7d90 + 6789441 commit 910b4ee

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

docs/StandardLibraryProgrammersManual.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,28 @@ For historical reasons, the existing codebase generally uses `internal` as the c
7272

7373
Every entry point in the standard library that has an ABI impact must be applied an `@available` attribute that describes the earliest ABI-stable OS releases that it can be deployed on. (Currently this only applies to macOS, iOS, watchOS and tvOS, since Swift isn't ABI stable on other platforms yet.)
7474

75-
Unlike access control modifiers, we prefer to put `@available` attributes on the extension context rather than duplicating them on every individual entry point. This is an effort to fight against information overload: the `@available` attribute is information dense and it's generally easier to review/maintain if applied to a group of entry points all at once.
75+
Just like access control modifiers, we prefer to put `@available` attributes on each individual access point, rather than just the extension in which they are defined.
7676

7777
```swift
78-
// 👍
78+
// 😢👎
7979
@available(macOS 10.6, iOS 10, watchOS 3, tvOS 12, *)
8080
extension String {
8181
public func blanch() { ... }
8282
public func roast() { ... }
8383
}
84+
85+
// 🥲👍
86+
extension String {
87+
@available(macOS 10.6, iOS 10, watchOS 3, tvOS 12, *)
88+
public func blanch() { ... }
89+
90+
@available(macOS 10.6, iOS 10, watchOS 3, tvOS 12, *)
91+
public func roast() { ... }
92+
}
8493
```
8594

95+
This coding style is enforced by the ABI checker -- it will complain if an extension member declaration that needs an availability doesn't have it directly attached.
96+
8697
Features under development that haven't been released yet must be marked with the placeholder version number `9999`. This special version is always considered available in custom builds of the Swift toolchain (including development snapshots), but not in any ABI-stable production release.
8798

8899
```swift

0 commit comments

Comments
 (0)