Date: Fri, 2 Jan 2026 17:30:31 -0600
On Fri, Jan 2, 2026 at 4:22 PM codusnocturnus via Std-Proposals <
std-proposals_at_[hidden]> wrote:
>
> On Friday, January 2nd, 2026 at 11:49 AM, Jan Schultke via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>
> What about a mixture of positional and named parameters?
>>
> I have some thoughts on that here:
> https://eisenwave.github.io/cpp-proposals/named-args.html#mixing-named-and-positional-arguments
>
> Things can get pretty confusing when mixing of positional and named
> arguments is permitted. The low-hanging fruit is to allow positional
> arguments at the start of the argument list, which has the obvious behavior
> of working exactly like positional arguments normally do.
>
> More recent versions of Kotlin allow you to mix positional and named
> arguments in the middle, but only within a prefix of arguments where if an
> argument is named, it needs to be in the same position as if it was
> provided positionally. For example, f(.first=0, 1) is valid, but f(.second=1,
> 0) is not. However, what Kotlin eventually made valid is unnecessarily
> ambitious for the first version of such a feature.
>
>
> I wonder if the mixed-use use case is a real thing, though? It's clearly a
> question to be addressed, but I imagine that people who want named
> parameters will always use them, and those who don't will never use them
> (unless/until forced).
>
> That said, variadic functions will present an interesting problem or two.
>
Yes, mixed-use is extremely common. Imagine an API where the first
parameter (or few) has obvious meaning but then there's a bunch after that
which do not. Examples might be matplotlib in python, where you do
plt.plot(xs, ys, lw=1, c="green") (
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.plot.html).
Another example is sorted(xs, key=f) (
https://docs.python.org/3/library/functions.html#sorted), where the
iterable is a position-only parameter, but on the other hand key and
reverse are keyword-only. That makes for a really clean API. Naming the
iterable parameter provides no value to the caller here, but the other two
do.
Python's approach in general here is quite nice:
def func(a, b, /, c, d, *, e, f):
pass
Here, a and b are positional-only, c and d are either, and e and f are
keyword-only. Having regional separators makes this easy to see visually.
Having a top-level attribute like [[positional]], on the other hand, is
just in the wrong place.
Barry
std-proposals_at_[hidden]> wrote:
>
> On Friday, January 2nd, 2026 at 11:49 AM, Jan Schultke via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>
> What about a mixture of positional and named parameters?
>>
> I have some thoughts on that here:
> https://eisenwave.github.io/cpp-proposals/named-args.html#mixing-named-and-positional-arguments
>
> Things can get pretty confusing when mixing of positional and named
> arguments is permitted. The low-hanging fruit is to allow positional
> arguments at the start of the argument list, which has the obvious behavior
> of working exactly like positional arguments normally do.
>
> More recent versions of Kotlin allow you to mix positional and named
> arguments in the middle, but only within a prefix of arguments where if an
> argument is named, it needs to be in the same position as if it was
> provided positionally. For example, f(.first=0, 1) is valid, but f(.second=1,
> 0) is not. However, what Kotlin eventually made valid is unnecessarily
> ambitious for the first version of such a feature.
>
>
> I wonder if the mixed-use use case is a real thing, though? It's clearly a
> question to be addressed, but I imagine that people who want named
> parameters will always use them, and those who don't will never use them
> (unless/until forced).
>
> That said, variadic functions will present an interesting problem or two.
>
Yes, mixed-use is extremely common. Imagine an API where the first
parameter (or few) has obvious meaning but then there's a bunch after that
which do not. Examples might be matplotlib in python, where you do
plt.plot(xs, ys, lw=1, c="green") (
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.plot.html).
Another example is sorted(xs, key=f) (
https://docs.python.org/3/library/functions.html#sorted), where the
iterable is a position-only parameter, but on the other hand key and
reverse are keyword-only. That makes for a really clean API. Naming the
iterable parameter provides no value to the caller here, but the other two
do.
Python's approach in general here is quite nice:
def func(a, b, /, c, d, *, e, f):
pass
Here, a and b are positional-only, c and d are either, and e and f are
keyword-only. Having regional separators makes this easy to see visually.
Having a top-level attribute like [[positional]], on the other hand, is
just in the wrong place.
Barry
Received on 2026-01-02 23:30:49
