Subject: Re: [std-proposals] Allow "default" keyword for default arguments
From: Henry Miller (hank_at_[hidden])
Date: 2020-02-05 05:45:26
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.
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 list run by herb.sutter at gmail.com
Standard Proposals Archives on Google Groups