Skip to content

Constraints on variadic pack arity, template phase arity and constant time query operations on packs #5093

Open
@CJ-Johnson

Description

@CJ-Johnson

Doc: https://docs.google.com/document/d/1bAG5UHqMw7i8Yoyv1wiIhG2dNlu5vLgOYvWyttYLges/

In case we decide we want to expand on the current variadics design to support symbolic phase pack arity constraints, template phase artity, and constant time query operations on a pack, I'm creating this as a long-term issue so the doc doesn't get lost and is hopefully eventually picked up as a proposal.

class Array(T:! type, N:! u32) {
  fn Make(...[== N] each t: T) -> Self {
    return {
      // In order for this line to compile, the constraint above must be applied.
      // Without the constraint, the type checker would have no way of
      // knowing if the pack was the same size as the backing array.
      .backing_array = (... each t),
    };
  }

  // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    design ideaAn issue recording a specific language design idea that folks can potentially pick up.long term issueIssues expected to take over 90 days to resolve. Does not apply to PRs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions