C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Allow "default" keyword for default arguments
From: Edward Diener (eldlistmailingz_at_[hidden])
Date: 2020-02-05 14:05:42


On 2/5/2020 6:45 AM, Henry Miller via Std-Proposals wrote:
>
> There is a persistent request for named parameters that comes up every few months in some form here. none have gone anywhere, but if any do in some future revision, it should cover this as a trivial extension. I don't think we want two different syntaxes for the same thing and it seems to me that naming the non default parameters makes more sense than saying some paramater is some default value.
>
> That is I think before you go too far you should consider how alternatives would look in real code.

Being a Boost C++ developer I am fully aware of the Boost Parameter
library, and how it is used, as a named parameter library.

I do not agree with your argument that because the future may hold some
other theoretical solution to this problem, the simple use of 'default'
for default arguments should not be considered now.

I still have no idea why Daniel Gutson's proposal was rejected, as it
seems it would have been trivial to implement and would have greatly
eased the use of default arguments from the end-user's side of things.
But then again the reason why the C++ standard committee accepts or
rejects anything proposed for C++ seems shrouded in mystery to me,
although perhaps those reasons are published somewhere on-line and I
just do not know where to look for them.

My own experience is that a highly flexible software library often
entails the extensive use of default template and function arguments.
This is a problem from the end-user's point of view in that overriding
some default argument often entails in repeating the default values of
some prior default arguments. It would be so much nicer for the end-user
to just specify the 'default' keyword when doing this than having to
look up and specify the actual default value. It would also signal to
anyone trying to understand such code that the end-user is just trying
to override a particular default while ignoring other defaults.

>
> On Tue, Feb 4, 2020, at 5:17 PM, Edward Diener via Std-Proposals wrote:
>> On 2/4/2020 3:46 PM, Daniel Gutson via Std-Proposals wrote:
>>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1466.pdf
>>> ?
>>
>> I personally would have left out the 'default<type>' syntax and would
>> have required in those cases that the programmer specify the default
>> value so the correct function could be invoked.
>>
>> Did you ever get any feedback if your proposal was discussed and, if so,
>> why it was rejected ?
>>
>>>
>>> El mar., 4 de feb. de 2020 a la(s) 13:43, Edward Diener via
>>> Std-Proposals (std-proposals_at_[hidden]
>>> <mailto: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] <mailto: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 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