Skip to content

Conversation

geoffromer
Copy link
Contributor

@geoffromer geoffromer commented Sep 30, 2022

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.

Copy link
Contributor

@josh11b josh11b left a 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.

Copy link
Contributor

@josh11b josh11b left a 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.

Copy link
Contributor

@chandlerc chandlerc left a 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 <[email protected]>
Co-authored-by: josh11b <[email protected]>
@josh11b josh11b dismissed their stale review October 3, 2024 22:58

Addressed

Copy link
Contributor

@chandlerc chandlerc left a 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.

Copy link
Contributor

@chandlerc chandlerc left a 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.

Copy link
Contributor

@chandlerc chandlerc left a 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.

@chandlerc chandlerc added this pull request to the merge queue Dec 11, 2024
Merged via the queue into carbon-language:trunk with commit 8e8d570 Dec 11, 2024
8 checks passed
@geoffromer geoffromer deleted the variadics branch January 10, 2025 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
long term issue Issues expected to take over 90 days to resolve. Does not apply to PRs. proposal rfc Proposal with request-for-comment sent out proposal A proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants