SE-0393: Value and Type Parameter Packs

FWIW I wrote a note on naming convention in the parameter pack vision document/extended future directions writeup from a few months back, where I recommend explicitly using either no argument label or a plural argument label when writing an API that uses parameter packs. I do think it's unfortunate that the default will be the singular name in the absence of a separate argument label, though.

An interesting aside on this document

I never updated this vision document for the repeat/each spelling proposed here because most of the content was incorporated into this proposal, but you can kinda see how we arrived on repeat/each from the explanations in the document :slightly_smiling_face:

In the section on patterned pack expansion

The ellipsis is called the expansion operator , and the type or expression that the expansion operator is applied to is called the repetition pattern . The repetition pattern must contain pack references. Given a concrete pack substitution, the pattern is repeated for each element in the substituted pack.

Consider a type parameter pack T and a pack expansion Mapped<T>... . Substituting the concrete pack {Int, String, Bool} will expand the pattern Mapped<T> by repeating it for each element in the concrete pack, replacing the pack reference T with the concrete type at each position. This produces a new comma-separated list of types Mapped<Int>, Mapped<String>, Mapped<Bool> .

In the note on naming convention

In the return type, the repetition pattern Optional<Element>... means there is an optional type for each individual element in the parameter pack. When this method is called on List<Int, String, Bool>, the pattern is repeated once for each individual type in the list, replacing the reference to Element with that individual type, resulting in Optional<Int>, Optional<String>, Optional<Bool>.

2 Likes