Skip to content

Commit

Permalink
Update 007-variadic-generics.md
Browse files Browse the repository at this point in the history
  • Loading branch information
csyonghe authored Sep 6, 2024
1 parent b4ae24d commit e63ac64
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/proposals/007-variadic-generics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit e63ac64

Please sign in to comment.