C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Implicitly accepting leading default function/template argument values

From: Bo Persson <bo_at_[hidden]>
Date: Sun, 6 Mar 2022 19:54:04 +0100
On 2022-03-06 at 17:17, David Jones via Std-Proposals wrote:
> ​Under your proposal, it would have to mean the same as "x = f(1, 2,
> /*some defaulted thing*/)".
>
> Under my proposal, "x = f(1,2,)" and "x = f(1,2)" would be identical, as
> long is f is a function with default values supplied for every argument
> after the second.
>

I'm not convinced that turning typos into valid code is an improvement. :-)

How do we know that f(1,2,) means "I want a default 3rd parameter" and
not "oops, I slipped on the keyboard"?

We had some other proposal resently using semicolons, where f(1;2) was
different from f(1,2). That could introduce a new class of hard to spot
single-pixel bugs!

So, not in favor of introducing this kind of subtle difference in
meaning that is easy to overlook.

Received on 2022-03-06 18:54:13