C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Flexible function parameters
From: Filippo Casarin (casarin.filippo17_at_[hidden])
Date: 2020-07-09 10:11:16


>
> This would probably need a more elaborate example here, as you can
> already get the specific functionality using an overload:
>
> void f(int x, int y);
>
> void f(int y)
> { f(0, y); }

Your code would break if I want to pass only x

Example:

> void f(int x, int y);
> void f(int y) { f(0, y); }
> void f(int x) ( f(x, 0); } // error
>
Solution:

> void f(int x=0; int y=0);
> foo(34;); // pass only `x`
> foo(;34); // pass only `y`
>

Il giorno gio 9 lug 2020 alle ore 16:58 Bo Persson via Std-Proposals <
std-proposals_at_[hidden]> ha scritto:

> On 2020-07-09 at 16:28, Jake Arkinstall via Std-Proposals wrote:
> > On Thu, 9 Jul 2020, 15:02 Arthur O'Dwyer, <arthur.j.odwyer_at_[hidden]
> > <mailto:arthur.j.odwyer_at_[hidden]>> wrote:
> >
> > On Thu, Jul 9, 2020 at 9:32 AM Jake Arkinstall via Std-Proposals
> > <std-proposals_at_[hidden]
> > <mailto:std-proposals_at_[hidden]>> wrote:
> >
> > The why is clear.
> >
> >
> > FWIW, no it's not. The OP didn't give any reason for the new syntax
> > at all. In fact, the OP didn't even say what the new syntax is
> > supposed to /*do!*/
> >
> >
> > I thought OP's code examples were rather clear. Though, granted, a wordy
> > explanation would be been helpful.
> >
> > What is `void f(int x, int y) {}` supposed to do differently from
> > `void f(int x; int y) {}`
> >
> >
> > Nothing, except that x can adopt a default value in the latter. Because
> > its a separate logical group, you have a way of telling the compiler
> > "adopt the defaults for the remainder of this parameter group".
> >
>
> This would probably need a more elaborate example here, as you can
> already get the specific functionality using an overload:
>
> void f(int x, int y);
>
> void f(int y)
> { f(0, y); }
>
>
> The committee is not that fond of new syntax for things already possible
> in the current language (with a few exceptions :-) ).
>
>
> Bo Persson
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>



STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups