Generic Arity: Definition-Checked Variadics in Carbon - Geoffrey Romer - C++Now 2024 @CppNow
Generic Arity: Definition-Checked Variadics in Carbon - Geoffrey Romer - C++Now 2024  @CppNow
Uploaded October 2024 | Updated December 2026, 2 hours ago
cppnow.org
---

Generic Arity: Definition-Checked Variadics in Carbon - Geoffrey Romer - C++Now 2024
---

In this talk, I will describe an approach to modeling variadic functions in the type system, by treating them as strongly typed functions that are generic over their arity, rather than as templates that are instantiated and then duck-typed. This forms the basis of the current proposed design for variadic functions in Carbon, an experimental C++ successor language.

Variadic functions are functions that are generic with respect to the arity (number of parameters), rather than only the types of the parameters. In C++, each instantiation of a generic function must be typechecked separately. However, in Carbon, generic functions can be definition-checked, meaning that the function body is fully type-checked once, using only the type constraints declared in the function signature. To extend Carbon's approach to variadic functions, we have to be able to reason about variadic argument lists as values with types, and solve problems like:

- How do we represent types with variadic components?
- How do we type-check function calls when we don't yet know which arguments correspond to which parameters?
- How can the syntax provide enough type information for definition checking to succeed, without overwhelming the business logic?

Carbon also prioritizes build performance, so we need a way to express variadic logic that can avoid the quadratic overhead (or worse) that often arises from C++'s recursion-oriented variadics model. And, as a C++ successor language, we need to do all that without compromising the expressive power of C++ variadics.

I will give an overview of how we plan to solve these problems in Carbon, enabling both tools and users to reason about the correctness of variadic code once and for all, rather than one instantiation at a time. You don't need previous familiarity with Carbon; I will introduce the relevant parts of the language as part of my talk.
---

Slides: github.com/boostcon/cppnow_presentations_2024/blob/main/Presentations/Generic_Arity.pdf


---

Geoffrey Romer

I'm a software engineer at Google, where I work on the Carbon project. I'm the lead designer for Carbon's support for sum types, subscripting, and variadics, among other things, and I've contributed extensively to the prototype Carbon interpreter. Prior to that I was a member of the C++ Libraries team, where I wrote Google's C++ concurrency guide, created the initial design for the Abseil hash framework, and authored the Core Coroutines C++ standard proposal. I'm also a co-owner of Google's C++ style guide.
---

C++Now 2025 - 28th April - 2nd May
C++Now is an annual onsite international C++ programming and coding conference held in Aspen, Colarado. For all C++ developers, C++ software engineers and those involved with the C++ language, CppNow provides an indepth and technical content provided by the best and brightest C++ experts of the C++ world.
Annual CppNow Conference - cppnow.org
linkedin.com/company/cppnow
twitter.com/cppnow
facebook.com/CppNow
reddit.com/r/CppNow
https://mastodon.social/@cppnow
think-cell develops one of the world’s leading PowerPoint applications, with C++ at the core of everything we build, from layout algorithms to deep integration with Microsoft Office. Interested in working on challenging C++ problems with real-world impact? Explore our open roles: think-cell.com/en/career/tech
---

Videos Filmed & Edited By Bash Films: bashfilms.com
YouTube Channel Managed & Optimized By Digital Medium Ltd: events.digital-medium.co.uk
---

#boost #cpp #cppprogramming #cplusplus #softwaredevelopment
Generic Arity: Definition-Checked Variadics in Carbon - Geoffrey Romer - C++Now 2024What Every C++ Programmer Needs to Know About AI - Jody Hagins - C++Now 2026C++Now 2024 Session Preview - Interview With Zach Laine by @cppeventsSignal Trees - A Deep Dive into a High-Performance Alternative to Queue-Based Task SchedulingLightning Talk: C++ Rvalue Ranges Aren’t Always Yours - Robert Leahy - C++Now 2025CMake’s Recent Evolution - Modules, CPS, and Build Optimization - Bill Hoffman - C++Now 2026How to Build a Flexible Robot Brain One Bit at a Time - Ramon Perez - C++Now 2025Coroutines for Dummies - Dominic Fischer - C++Now 2026Functional C++ - Gašper Ažman - C++Now 2024C++ Libraries - The Road Ahead - Jeffrey Garland - C++Now 2026The Importance of the C++ Build System Target Model - Bill Hoffman - C++Now 2024After Reflection: The Runtime Story - Saksham Sharma - C++Now 2026
CppNow |

Generic Arity: Definition-Checked Variadics in Carbon - Geoffrey Romer - C++Now 2024

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER