Date: Tue, 12 Nov 2019 00:32:42 -0500
On 11/11/2019 11:03 PM, Andrew Tomazos via Std-Proposals wrote:
> +std-proposals
>
> I actually think it would be better to have named parameters. That way:
>
> auto fooval = foo(13, default, default, &foobazval);
>
> is instead:
>
> auto fooval = foo(bar: 13, foobaz: &foobazval);
>
> which I think reads a lot better. I suspect you only want this default
> feature so that you can default parameters in the middle of the list
> without defaulting those at the end.
Boost already has a named parameters implementation which can be used
using the template facilities of C++ as specified in the docs for the
Boost Parameters library. While I like very much what Boost offers, and
have used it myself, I think the first form would still be extremely
useful and very easy to implement as part of the C++ language. And yes,
of course I would like to use the proposed 'default' in the middle of a
list since there is no reason to use it at the end where just not
passing any argument automatically defaults to the default value. But of
course there is no reason why the proposed 'default' could not be used
at the end of a list of default parameters if that would make the
programmer feel comfortable, even if it is totally unnecessary.
Sometimes a simple idea which is easy to implement and enhances a
programming idiom, ie the necessity of having to know and specify the
default value before specifying a specific value when invoking a C++
construct with more than one default value, is totally justified based
on ease of use even when a more complicated but richer syntactic idiom,
ie. named parameters, is also a solution. I think the 'default' keyword
as an argument to automatically specify the default value of a parameter
is such a case.
>
>
> On Tue, Nov 12, 2019 at 3:00 AM Vishal Oza via Std-Discussion
> <std-discussion_at_[hidden]
> <mailto:std-discussion_at_[hidden]>> wrote:
>
> I just wanted to know if the following idea is a bad idea. Should we
> enable using the default keyword to function input value parameter
> if we only care about one parameter that have default parameters
> both before and after the parameter we care about?
> For example:
>
> int foo(int bar = 3, int baz = 7, int* foobar = nullptr, int* foobaz
> = nullptr) { ... }
> ...
>
> int foobazval = 78;
> auto fooval = foo(13, default, default, &foobazval); // =
> foo(13, 7, nullptr, &foobazval)
>
>
> The exceptions are references where there should never be a
> default value and possibly type with no default this is only a
> possibly because the type could be the same value as the type if the
> type was default constructed.
> +std-proposals
>
> I actually think it would be better to have named parameters. That way:
>
> auto fooval = foo(13, default, default, &foobazval);
>
> is instead:
>
> auto fooval = foo(bar: 13, foobaz: &foobazval);
>
> which I think reads a lot better. I suspect you only want this default
> feature so that you can default parameters in the middle of the list
> without defaulting those at the end.
Boost already has a named parameters implementation which can be used
using the template facilities of C++ as specified in the docs for the
Boost Parameters library. While I like very much what Boost offers, and
have used it myself, I think the first form would still be extremely
useful and very easy to implement as part of the C++ language. And yes,
of course I would like to use the proposed 'default' in the middle of a
list since there is no reason to use it at the end where just not
passing any argument automatically defaults to the default value. But of
course there is no reason why the proposed 'default' could not be used
at the end of a list of default parameters if that would make the
programmer feel comfortable, even if it is totally unnecessary.
Sometimes a simple idea which is easy to implement and enhances a
programming idiom, ie the necessity of having to know and specify the
default value before specifying a specific value when invoking a C++
construct with more than one default value, is totally justified based
on ease of use even when a more complicated but richer syntactic idiom,
ie. named parameters, is also a solution. I think the 'default' keyword
as an argument to automatically specify the default value of a parameter
is such a case.
>
>
> On Tue, Nov 12, 2019 at 3:00 AM Vishal Oza via Std-Discussion
> <std-discussion_at_[hidden]
> <mailto:std-discussion_at_[hidden]>> wrote:
>
> I just wanted to know if the following idea is a bad idea. Should we
> enable using the default keyword to function input value parameter
> if we only care about one parameter that have default parameters
> both before and after the parameter we care about?
> For example:
>
> int foo(int bar = 3, int baz = 7, int* foobar = nullptr, int* foobaz
> = nullptr) { ... }
> ...
>
> int foobazval = 78;
> auto fooval = foo(13, default, default, &foobazval); // =
> foo(13, 7, nullptr, &foobazval)
>
>
> The exceptions are references where there should never be a
> default value and possibly type with no default this is only a
> possibly because the type could be the same value as the type if the
> type was default constructed.
Received on 2019-11-11 23:37:24