@@ -18,12 +18,46 @@ source code, tests, and commit messages. See also the `LLVM lexicon`_.
18
18
19
19
.. glossary ::
20
20
21
+ abstraction pattern
22
+ The unsubstituted generic type of a property or function parameter, which
23
+ sets constraints on its representation in memory. For example, given the
24
+ following definitions::
25
+
26
+ struct Foo<T> {
27
+ var value: T
28
+ // Foo.value has abstraction pattern <T> T
29
+
30
+ struct Bar<T, U> {
31
+ var value: (T) -> U
32
+ // Bar.value has abstraction pattern <T, U> (T) -> U
33
+ }
34
+ struct Bas {
35
+ var value: (Int) -> String
36
+ // Bas.value has abstraction pattern (Int) -> String
37
+ }
38
+ let transform: (Int) -> String = { "\($0)" }
39
+ let foo = Foo<(Int) -> String>(value: transform)
40
+ let bar = Bar<Int, String>(value: transform)
41
+ let bas = Bas(value: transform)
42
+
43
+ although ``foo.value ``, ``bar.value ``, and ``bas.value `` all have the same
44
+ function type ``(Int) -> String ``, they have different *abstraction
45
+ patterns *. Because a value of type ``Foo `` or ``Bar `` may be used in a
46
+ generic context and invoke ``value `` with a parameter or result type
47
+ of unknown size, the compiler has to pick a more conservative representation
48
+ for the closure that uses indirect argument passing, whereas ``Bas.value ``
49
+ has a fully concrete closure type so can always use a more specialized
50
+ direct register-based calling convention. The compiler transparently
51
+ introduces `reabstraction ` conversions when a value is used with a
52
+ different abstraction pattern. (This is where the infamous "reabstraction
53
+ thunk helpers" sometimes seen in Swift backtraces come from.)
54
+
21
55
archetype
22
56
A placeholder for a generic parameter or an associated type within a
23
57
generic context. Sometimes known as a "rigid type variable" in formal
24
58
CS literature. Directly stores its conforming protocols and nested
25
59
archetypes, if any.
26
-
60
+
27
61
AST
28
62
"Abstract syntax tree", although in practice it's more of a directed graph.
29
63
A parsed representation of code used by a compiler.
@@ -235,6 +269,10 @@ source code, tests, and commit messages. See also the `LLVM lexicon`_.
235
269
IR generation.
236
270
See `mandatory passes <mandatory passes / mandatory optimizations> `.
237
271
272
+ reabstraction
273
+ An implicit representation change that occurs when a value is used with
274
+ a different `abstraction pattern ` from its current representation.
275
+
238
276
resilient
239
277
Describes a type or function where making certain changes will not break
240
278
binary compatibility. See :doc: `LibraryEvolution.rst <LibraryEvolution >`.
0 commit comments