summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-09-05 21:11:09 -0700
committerGitHub <noreply@github.com>2024-09-05 21:11:09 -0700
commite63ac64944635472a27c8adc730b08ffc445f8e4 (patch)
tree3afabdf7d98d715c4cfcf1bf3acd5628bac76a19
parentb4ae24dd079d86d34a84eb84a6c30937db47bf18 (diff)
Update 007-variadic-generics.md
-rw-r--r--docs/proposals/007-variadic-generics.md11
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/proposals/007-variadic-generics.md b/docs/proposals/007-variadic-generics.md
index ed2754183..9249119f7 100644
--- a/docs/proposals/007-variadic-generics.md
+++ b/docs/proposals/007-variadic-generics.md
@@ -222,6 +222,14 @@ Similarly, when using `expand` and `each` on values, we require that:
- The pattern expression of an `expand` expression must capture at least one value whose type is a generic type pack parameter.
- The expression after `each` must refer to a value whose type is a generic type pack parameter, and the `each` expression can only appear inside an `expand` expression.
+Combined with type euqality constriants, variadic generic type pack can be used to define homogeneously typed parameter pack:
+```
+void calcInts<each T>(expand each T values) where T == int
+{
+ ...
+}
+```
+
Detailed Explanation
--------------------
@@ -537,6 +545,9 @@ For example, the type `expand vector<each T, each U>`, where `T` and `U` are gen
%expandType = IRExpandType(%v, %T, %U) // v is pattern; T,U are captured type packs.
```
+Note that this kind of type hierarchy representation is only used during IR lowering in order to benefit from IR global deduplication of type definitions. The representation in this form isn't convenient for specialization.
+Once lowered to IR step is complete, we will convert all type representation to the same form as value represenataion described in the following section.
+
#### Expressing Values
A value whose type is a type pack is called a value pack. A value pack is represented in the IR as a `IRMakeValuePack` inst.