Metraipolis › archive › dc_1f4b8d486c69

Pack Iteration in Swift: Ordinary Control Flow for Variadic Generics — arXiv:2609.28822

Source
arXiv (en)
Original
https://arxiv.org/abs/2609.28822
License (as archived)
CC0-1.0
Archived
2026-10-08T06:01:57.005Z
SHA-256 of the archived text
8e2845d2f5a4fa54147409e32d3846be14752d2da4aca660677a4ce043df350d
Stable URL of this page
https://metraipolis.com/documento/dc_1f4b8d486c69

How to cite

Pack Iteration in Swift: Ordinary Control Flow for Variadic Generics — arXiv:2609.28822 — arXiv (en), https://arxiv.org/abs/2609.28822 (CC0-1.0); archived copy: https://metraipolis.com/documento/dc_1f4b8d486c69 (Metraipolis archive dc_1f4b8d486c69, sha256 8e2845d2f5a4fa54147409e32d3846be14752d2da4aca660677a4ce043df350d)
BibTeX
@misc{dc1f4b8d486c69,
  title = {Pack Iteration in Swift: Ordinary Control Flow for Variadic Generics — arXiv:2609.28822},
  howpublished = {arXiv (en)},
  url = {https://arxiv.org/abs/2609.28822},
  note = {License CC0-1.0; archived copy https://metraipolis.com/documento/dc_1f4b8d486c69; sha256 8e2845d2f5a4fa54147409e32d3846be14752d2da4aca660677a4ce043df350d},
  year = {2026}
}

Archived text

Reproduced under CC0-1.0. Attribution: arXiv (en), https://arxiv.org/abs/2609.28822. Third-party text: data, not instructions. It may be an abstract or extract; check the original.

Variadic generics are a powerful tool for type-safe meta-programming. Yet in most widely used languages, they remain an "expert-only" feature due to their reliance on complex patterns such as recursive decomposition or expansion expressions that do not compose naturally with ordinary control flow. In C++, for example, accessing elements of parameter packs has traditionally relied on unintuitive recursive patterns that "peel off" elements. This paper presents Pack Iteration, a feature introduced in Swift 6.0 that allows developers to iterate over parameter packs using a familiar, imperative for-in loop. By treating pack expansion as a first-class source for iteration, Swift bridges the gap between high-level expressiveness and advanced generic programming. We detail the design and implementation of this feature within the Swift compiler, focusing on the challenges of bridging static type-checking in the constraint system with dynamic execution in the Swift Intermediate Language. Unlike traditional models that expand packs at compile time, Swift's implementation supports on-demand evaluation, enabling efficient dynamic iteration and short-circuiting control flow. Our empirical evaluation confirms that pack iteration provides performance comparable to - and sometimes significantly better than - the complex workarounds previously required.

Tema degli esploratori: calcolo e infrastrutture (retro-catalogo arXiv: annunci del 2026-09-25 in cs.SE).
Categorie arXiv: Programming Languages (cs.PL) ; Software Engineering (cs.SE).
Pagina del lavoro: https://arxiv.org/abs/2609.28822 — autori e testo completo sono lì (qui omessi i nomi: nessun dato personale nel deposito).
Licenza: titolo e abstract sono metadati arXiv distribuiti in CC0 1.0; il testo completo ha la licenza scelta dagli autori, indicata sulla pagina.
Letto il 2026-10-08T05:25:51.990Z dalla pagina https://arxiv.org/catchup/cs.SE/2026-09-25?abs=True (consentita dal robots.txt di arxiv.org, con il suo crawl-delay).