-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Variadics #2240
Proposal: Variadics #2240
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made another pass without diving into the type checking bits, since those seem like something that could be handled in a separate proposal once the other issues are handled.
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
Co-authored-by: josh11b <15258583+josh11b@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! I think this is ready for leads review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all but the appendix (largely trusting Josh's review there) and generally pretty happy across the board. Left a bunch of comments, but mostly minor wording / presentation improvements.
Co-authored-by: Chandler Carruth <chandlerc@gmail.com> Co-authored-by: josh11b <15258583+josh11b@users.noreply.github.com>
Co-authored-by: Carbon Infra Bot <carbon-external-infra@google.com>
Co-authored-by: josh11b <15258583+josh11b@users.noreply.github.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this LG, but should confirm that other leads don't want a last look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this LG, but should confirm that other leads don't want a last look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, all of the leads have looked at this at this point (sorry for it taking a while), but we're all happy. Approving and hitting the merge button.
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 <josh11b@users.noreply.github.com> Co-authored-by: Richard Smith <richard@metafoo.co.uk> Co-authored-by: josh11b <15258583+josh11b@users.noreply.github.com> Co-authored-by: Chandler Carruth <chandlerc@gmail.com> Co-authored-by: Carbon Infra Bot <carbon-external-infra@google.com>
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 ofcompile-time loop over sequences called "packs". Packs are initialized and
referred to using "pack bindings", which are marked with the
each
keyword atthe 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
...
:...
iteratively evaluates its operand expression, and treats the values as
successive elements of the tuple.
...and
and...or
iteratively evaluate a boolean expression, combiningthe values using
and
andor
, and ending the loop early if the underlyingoperator short-circuits.
...
iteratively executes a statement....
iteratively matches the elements of the scrutinee tuple. In conjunction with
pack bindings, this enables functions to take an arbitrary number of
arguments.