C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Allow "default" keyword for default arguments
From: Daniel Gutson (danielgutson_at_[hidden])
Date: 2020-02-04 14:46:33


http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1466.pdf
?

El mar., 4 de feb. de 2020 a la(s) 13:43, Edward Diener via Std-Proposals (
std-proposals_at_[hidden]) escribió:

> My proposal is simply that whenever a template argument or a function
> argument has a default value the keyword "default" can be used to
> specify that value when instantiating a template or calling a function.
>
> The proverbial case for this is when a template or a function has more
> than one default value and the programmer wants to specify a value for a
> default while accepting other default values, whatever they may be. In
> this case I do not think it should be necessary for the programmer to
> know or care what the other default values are in order to set value(s)
> for particular defaults. By using the "default" keyword the programmer
> can do this more easily. In my proposal the use of the keyword "default"
> for a template or function argument which does not have a default value
> is a compiler error.
>
> I am aware of someone else's proposal along the same lines but I want to
> disassociate myself from that proposal completely, as it attempted to
> add a number of unnecessary and irrelevant provisos. My proposal is
> straightforward and is not intended to represent anything more
> complicated than what I have stated above.
>
> I have no idea whether this has ever been proposed officially to the C++
> standards committee, or what the outcome of such a proposal was, but if
> anybody does know I would be curious why the proposal was rejected. I am
> aware of workarounds to the issue which I intend to solve with this
> proposal, and I am aware of the attitude that the programmer should have
> to know and actively repeat a default value in order to specify
> arguments for further default values in positional arguments, but I see
> no reason why using the "default" keyword could not be used to make
> things easier for the programmer in this respect. Ease of language use
> should be important, especially when that ease incurs no great effort in
> implementation, which I believe my proposal entails.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

-- 
Who’s got the sweetest disposition?
One guess, that’s who?
Who’d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?


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

Standard Proposals Archives on Google Groups