C++ Logo

std-proposals

Advanced search

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

From: Lénárd Szolnoki <cpp_at_[hidden]>
Date: Sun, 6 Mar 2022 19:03:00 +0000
Hi,

On Sun, 6 Mar 2022 19:54:04 +0100
Bo Persson via Std-Proposals <std-proposals_at_[hidden]> wrote:

> 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"?

In my understanding f(1,2,) and f(1,2) could mean the same thing
always, not only when there are default parameters in the function
declaration. So there is no "subtle difference" to worry about.

> 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.
>
>
>
>
>

Cheers,
Lénárd

Received on 2022-03-06 19:03:10