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/ABI/GenericSignature.md
+13-14
Original file line number
Diff line number
Diff line change
@@ -41,14 +41,14 @@ Consider the following generic signature:
41
41
The constraint `C1.Element: Equatable` is redundant (because it can be proven based on `C1.Element == C2.Element` and `C2.Element: Equatable`). Similarly, `C2.Element: Equatable` is redundant (based on `C1.Element == C2.Element` and `C1.Element: Equatable`). Either one of these constraints can be removed without changing the semantics of the generic signature, and the resulting generic signature will be minimal (there are no redundant constraints that remain). As such, there are two minimal generic signatures that describe this set of constraints:
42
42
43
43
```swift
44
-
<C1, C2 where C1:Collection, C2:Collection, C1.Element:Equatable,
44
+
<C1, C2 where C1:Collection, C2:Collection, C1.Element:Equatable,
45
45
C1.Element== C2.Element>
46
46
```
47
47
48
48
and
49
49
50
50
```swift
51
-
<C1, C2 where C1:Collection, C2:Collection, C1.Element== C2.Element,
51
+
<C1, C2 where C1:Collection, C2:Collection, C1.Element== C2.Element,
52
52
C2.Element:Equatable>
53
53
```
54
54
@@ -60,19 +60,19 @@ A generic signature is *canonical* when each of its constraints is [canonical](#
60
60
61
61
1. Generic type parameters are listed first
62
62
ordered by [type parameter ordering](#type-parameter-ordering)
63
-
2. Constraints follow, ordered first by the
64
-
[type parameter ordering](#type-parameter-ordering) of the left-hand
63
+
2. Constraints follow, ordered first by the
64
+
[type parameter ordering](#type-parameter-ordering) of the left-hand
65
65
operand and then by constraint kind. The left-hand side of a constraint
66
66
is always a type parameter (call it `T`).
67
67
Constraints are ordered as follows:
68
68
1. A superclass constraint `T: C`, where `C` is a class.
69
69
2. A layout constraint (e.g., `T: some-layout`), where the right-hand
70
-
side is `AnyObject` or one of the non-user-visible layout constraints
70
+
side is `AnyObject` or one of the non-user-visible layout constraints
71
71
like `_Trivial`.
72
-
3. Conformance constraints `T: P`, where `P` is a protocol. The
73
-
conformance constraints for a given type parameter `T` are further
72
+
3. Conformance constraints `T: P`, where `P` is a protocol. The
73
+
conformance constraints for a given type parameter `T` are further
74
74
sorted using the [protocol ordering](#protocol-ordering).
75
-
4. A same-type constraint `T == U`, where `U` is either a type parameter
75
+
4. A same-type constraint `T == U`, where `U` is either a type parameter
76
76
or a concrete type.
77
77
78
78
### Type parameter ordering
@@ -117,7 +117,7 @@ Each equivalence class has a corresponding *anchor*, which is a type parameter t
117
117
118
118
A layout or conformance constraint is canonical when its left-hand side is the anchor of its equivalence class. A superclass constraint is canonical when its left-hand side is the anchor of its equivalence class and its right-hand side is a canonical concrete (class) type. Same-type constraint canonicalization is discussed in detail in the following section, but some basic rules apply: the left-hand side is always a type parameter, and the right-hand side is either a type parameter that follows the left-hand side (according to the [type parameter ordering](#type-parameter-ordering)) or is a canonical concrete type.
119
119
120
-
### Same-type constaints
120
+
### Same-type constraints
121
121
122
122
The canonical form of superclass, layout, and conformance constraints are directly canonicalizable once the equivalence classes are known. Same-type constraints, on the other hand, are responsible for forming those equivalence classes. Let's expand our running example to include a third `Collection`:
123
123
@@ -138,13 +138,13 @@ or
138
138
C1.Element== C2.Element, C2.Element== C3.Element
139
139
```
140
140
141
-
or
141
+
or
142
142
143
143
```swift
144
144
C1.Element== C3.Element, C2.Element== C3.Element
145
145
```
146
146
147
-
All of these sets of constraints have the same effect (i.e., form the same equivalence class), but the second one happens to be the canonical form.
147
+
All of these sets of constraints have the same effect (i.e., form the same equivalence class), but the second one happens to be the canonical form.
148
148
149
149
The canonical form is determined by first dividing all of the types in the same equivalence class into distinct components. Two types `T1` and `T2` are in the same component if the same type constraint `T1 == T2` can be proven true based on other known constraints in the generic signature (i.e., if `T1 == T2` would be redundant). For example, `C1.Element` and `C1.SubSequence.Elemenent` are in the same component, because `C1: Collection` and the `Collection` protocol contains the constraint `Element == SubSequence.Element`. However, `C1.Element` and `C2.Element` are in different components.
150
150
@@ -162,15 +162,15 @@ For the first case, consider a function that operates on `String` collections:
This protocol introduces a number of constraints: `Self: Sequence` (stated as inheritance), `Self.SubSequence: Collection` (in the protocol where clause), `Self.Indices: Collection` (associated type declaration) and `Self.Indices.Element == Index` (associated type where clause). These constraints, which are directly implied by `Self: Collection`, form the *requirement signature* of a protocol. As with other generic signatures used for the ABI, the requirement signature is minimal and canonical according to the rules described elsewhere in this document.
Copy file name to clipboardExpand all lines: docs/StandardLibraryProgrammersManual.md
+5-7
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ TODO: Should this subsume or link to [AccessControlInStdlib.rst](https://github.
12
12
1. Library Organization
13
13
1. What files are where
14
14
1. Brief about CMakeLists
15
-
1. Brief about GroupInfo.json
15
+
1. Brief about GroupInfo.json
16
16
1. What tests are where
17
17
1. Furthermore, should there be a split between whitebox tests and blackbox tests?
18
18
1. What benchmarks are where
@@ -23,7 +23,7 @@ TODO: Should this subsume or link to [AccessControlInStdlib.rst](https://github.
23
23
1. Protocol hierarchy
24
24
1. Customization hooks
25
25
1. Use of classes, COW implementation, buffers, etc
26
-
1.Compatiblity, `@available`, etc.
26
+
1.Compatibility, `@available`, etc.
27
27
1. Resilience, ABI stability, `@_inlineable`, `@_versioned`, etc
28
28
1. Strings and ICU
29
29
1. Lifetimes
@@ -75,8 +75,8 @@ if _fastPath(...) {
75
75
...
76
76
if_fastPath(...) {
77
77
// 9% of the time we execute this: very conservative inlining
78
-
...
79
-
return
78
+
...
79
+
return
80
80
}
81
81
82
82
// 1% of the time we execute this: very conservative inlining
@@ -87,7 +87,7 @@ return
87
87
*NOTE: these are due for a rename and possibly a redesign. They conflate multiple notions that don’t match the average standard library programmer’s intuition.*
88
88
89
89
90
-
#### `_onFastPath`
90
+
#### `_onFastPath`
91
91
92
92
This should be rarely used. It informs the SIL optimizer that any code dominated by it should be treated as the innermost loop of a performance critical section of code. It cranks optimizer heuristics to 11. Injudicious use of this will degrade performance and bloat binary size.
93
93
@@ -170,5 +170,3 @@ The standard library utilizes thread local storage (TLS) to cache expensive comp
170
170
3. If the field is not trivially destructable, update `_destroyTLS` to properly destroy the value.
171
171
172
172
See [ThreadLocalStorage.swift](https://github.com/apple/swift/blob/master/stdlib/public/core/ThreadLocalStorage.swift) for more details.
0 commit comments