C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Proposal: template function solution to Pythonic optional function arguments
From: Richard Hodges (hodges.r_at_[hidden])
Date: 2020-07-20 09:43:15


On Mon, 20 Jul 2020 at 18:03, codusnocturnus via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> This would be great - just remove the braces, and the .’s, and the struct.
>

At this point it becomes an argument over syntax, rather than functional
outcomes.

I think what the designated initialiser demo shows is that the language is
capable of accommodating this idea.

I suspect the bigger argument will be over whether it should, given the
additional overhead of passing carrying unnecessary optionals into a
function whether it needs them or not.

I think it's common to think, "language X has a nice way of expressing Y -
why don't we do that too?"

I can be guilty of that just like anyone else.

But in the end, if a language gives you a way to *express intent*, one
might wonder whether it's worth expending effort in making syntax nicer for
niche use cases in favour of providing more utility or fixing design bugs.

>
> Sent from ProtonMail Mobile
>
>
> On Mon, Jul 20, 2020 at 2:10 AM, Richard Hodges via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>
>>
>> Its possible something like this already exists in the latest versions of
>> C++ but if so I am not aware of it
>>
>
> As of C++20, one could use designated initialisers to achieve this.
>
> Whether it's a good idea in C++ is another matter.
>
> https://godbolt.org/z/cd8szq
>
>
>
> --
> Richard Hodges
> hodges.r_at_[hidden]
> office: +442032898513
> home: +376841522
> mobile: +376380212
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

-- 
Richard Hodges
hodges.r_at_[hidden]
office: +442032898513
home: +376841522
mobile: +376380212


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

Standard Proposals Archives on Google Groups