C++ Logo

std-proposals

Advanced search

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

From: Keenan Horrigan <friedkeenan_at_[hidden]>
Date: Sun, 06 Mar 2022 19:01:06 +0000
The lack of anything in between the commas particularly makes me think this would be a poor addition to the language. It'd be easy to miss, easy to typo, and easy to think it's a typo.

I'm not sure I'd support this either, but using the already-a-keyword "default" as a parameter could be used to explicitly use the default value for a parameter, used like f(1, default, 3)

------- Original Message -------

On Sunday, March 6th, 2022 at 12:54 PM, 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"?
>
> 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.
>
> --
>
> Std-Proposals mailing list
>
> Std-Proposals_at_[hidden]
>
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2022-03-06 19:01:11