From e63ac64944635472a27c8adc730b08ffc445f8e4 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 5 Sep 2024 21:11:09 -0700 Subject: [PATCH] Update 007-variadic-generics.md --- docs/proposals/007-variadic-generics.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/proposals/007-variadic-generics.md b/docs/proposals/007-variadic-generics.md index ed27541839..9249119f78 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(expand each T values) where T == int +{ + ... +} +``` + Detailed Explanation -------------------- @@ -537,6 +545,9 @@ For example, the type `expand vector`, 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.