-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit 8e8d570
Proposal: Variadics (#2240)
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]>1 parent 14724a5 commit 8e8d570Copy full SHA for 8e8d570
File tree
Expand file treeCollapse file tree
3 files changed
+2092
-10
lines changedFilter options
- docs
- design
- project/principles
- proposals
Expand file treeCollapse file tree
3 files changed
+2092
-10
lines changed
0 commit comments