C++ Logo


Advanced search

Re: [std-proposals] Explicitly specifying default arguments

From: Zhihao Yuan <zy_at_[hidden]>
Date: Wed, 01 Feb 2023 23:58:10 +0000
On Wednesday, February 1st, 2023 at 7:39 AM, Andrey Semashev via Std-Proposals <std-proposals_at_[hidden]> wrote:


> In any case, my proposal is not about named arguments, it's about
> simplifying passing the defaults, that's it.

I understand that you see a problem, but
the outcome of the suggestion may need
to be verified. Consider a code base where
everything is passed via smart pointers.
You see a function call like this:

  service->CreateConnection(nullptr, URL, nullptr, nullptr, payload, nullptr);

Every parameter, presumably other than
the first two, defaults to nullptr. Does
it help, to change the call into

  service->CreateConnection(nullptr, URL, default, default, payload, default);


It looks like "explicit default" looks
equally good or bad compared to its prior

Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.

Received on 2023-02-01 23:58:17