You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/StandardLibraryProgrammersManual.md
+13-2Lines changed: 13 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,17 +72,28 @@ For historical reasons, the existing codebase generally uses `internal` as the c
72
72
73
73
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.)
74
74
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.
76
76
77
77
```swift
78
-
//👍
78
+
//😢👎
79
79
@available(macOS10.6, iOS10, watchOS3, tvOS12, *)
80
80
extensionString {
81
81
publicfuncblanch() { ... }
82
82
publicfuncroast() { ... }
83
83
}
84
+
85
+
// 🥲👍
86
+
extensionString {
87
+
@available(macOS10.6, iOS10, watchOS3, tvOS12, *)
88
+
publicfuncblanch() { ... }
89
+
90
+
@available(macOS10.6, iOS10, watchOS3, tvOS12, *)
91
+
publicfuncroast() { ... }
92
+
}
84
93
```
85
94
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
+
86
97
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.
0 commit comments