Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proposes a set of core features for declaring and implementing generic variadic functions. A "pack expansion" is a syntactic unit beginning with `...`, which is a kind of compile-time loop over sequences called "packs". Packs are initialized and referred to using "pack bindings", which are marked with the `each` keyword at the point of declaration and the point of use. The syntax and behavior of a pack expansion depends on its context, and in some cases by a keyword following the `...`: - In a tuple literal expression (such as a function call argument list), `...` iteratively evaluates its operand expression, and treats the values as successive elements of the tuple. - `...and` and `...or` iteratively evaluate a boolean expression, combining the values using `and` and `or`, and ending the loop early if the underlying operator short-circuits. - In a statement context, `...` iteratively executes a statement. - In a tuple literal pattern (such as a function parameter list), `...` iteratively matches the elements of the scrutinee tuple. In conjunction with pack bindings, this enables functions to take an arbitrary number of arguments. --------- Co-authored-by: josh11b <[email protected]> Co-authored-by: Richard Smith <[email protected]> Co-authored-by: josh11b <[email protected]> Co-authored-by: Chandler Carruth <[email protected]> Co-authored-by: Carbon Infra Bot <[email protected]>
- Loading branch information