Topic: Non-last default arguments
Author: Avi Kivity <avi@scylladb.com>
Date: Thu, 6 Apr 2017 18:12:19 +0300
Raw View
I'm sure this was suggested before, but couldn't find it on google:
void f(int x = 1, int y = 2, int z = 3);
f(); // 1, 2, 3
f(6, 7); // 6, 7, 3
f(default, 7); // 1, 7, 3
struct car {
unsigned long long int wheels = 4;
string color = "yellow";
};
auto my_car = car{default, "red"}; // 4ULL wheels
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/91d734b5-d1f2-773a-b5c2-3b96696a6f0f%40scylladb.com.
.
Author: "dgutson ." <danielgutson@gmail.com>
Date: Thu, 6 Apr 2017 12:17:39 -0300
Raw View
--001a11409dae8204af054c810245
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
see the date:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1466.pdf
On Thu, Apr 6, 2017 at 12:12 PM, Avi Kivity <avi@scylladb.com> wrote:
> I'm sure this was suggested before, but couldn't find it on google:
>
>
>
> void f(int x =3D 1, int y =3D 2, int z =3D 3);
>
>
> f(); // 1, 2, 3
>
> f(6, 7); // 6, 7, 3
>
> f(default, 7); // 1, 7, 3
>
>
> struct car {
>
> unsigned long long int wheels =3D 4;
>
> string color =3D "yellow";
>
> };
>
>
> auto my_car =3D car{default, "red"}; // 4ULL wheels
>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit https://groups.google.com/a/is
> ocpp.org/d/msgid/std-proposals/91d734b5-d1f2-773a-b5c2-
> 3b96696a6f0f%40scylladb.com.
>
--=20
Who=E2=80=99s got the sweetest disposition?
One guess, that=E2=80=99s who?
Who=E2=80=99d 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?
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAFdMc-2Q8FyP-qqJCT-zDj4kfrqQ89G4qdWuWtVJAzDvFuO=
Z5w%40mail.gmail.com.
--001a11409dae8204af054c810245
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">see the date: <a href=3D"http://www.open-std.org/jtc1/sc22=
/wg21/docs/papers/2003/n1466.pdf">http://www.open-std.org/jtc1/sc22/wg21/do=
cs/papers/2003/n1466.pdf</a><br></div><div class=3D"gmail_extra"><br><div c=
lass=3D"gmail_quote">On Thu, Apr 6, 2017 at 12:12 PM, Avi Kivity <span dir=
=3D"ltr"><<a href=3D"mailto:avi@scylladb.com" target=3D"_blank">avi@scyl=
ladb.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm =
sure this was suggested before, but couldn't find it on google:<br>
<br>
<br>
<br>
void f(int x =3D 1, int y =3D 2, int z =3D 3);<br>
<br>
<br>
f();=C2=A0 // 1, 2, 3<br>
<br>
f(6, 7); // 6, 7, 3<br>
<br>
f(default, 7); // 1, 7, 3<br>
<br>
<br>
struct car {<br>
<br>
=C2=A0 =C2=A0 unsigned long long int wheels =3D 4;<br>
<br>
=C2=A0 =C2=A0 string color =3D "yellow";<br>
<br>
};<br>
<br>
<br>
auto my_car =3D car{default, "red"};=C2=A0 // 4ULL wheels<span cl=
ass=3D"HOEnZb"><font color=3D"#888888"><br>
<br>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isoc<wbr>pp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/91d734b5-d1f2-773a-b5c2-3b96696a6f0f%=
40scylladb.com" rel=3D"noreferrer" target=3D"_blank">https://groups.google.=
com/a/is<wbr>ocpp.org/d/msgid/std-proposals<wbr>/91d734b5-d1f2-773a-b5c2-<w=
br>3b96696a6f0f%40scylladb.com</a>.<br>
</font></span></blockquote></div><br><br clear=3D"all"><br>-- <br><div clas=
s=3D"gmail_signature" data-smartmail=3D"gmail_signature">Who=E2=80=99s got =
the sweetest disposition?<br>One guess, that=E2=80=99s who?<br>Who=E2=80=99=
d never, ever start an argument?<br>Who never shows a bit of temperament?<b=
r>Who's never wrong but always right?<br>Who'd never dream of start=
ing a fight?<br>Who get stuck with all the bad luck? </div>
</div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAFdMc-2Q8FyP-qqJCT-zDj4kfrqQ89G4qdWu=
WtVJAzDvFuOZ5w%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFdMc-2Q8FyP-qqJ=
CT-zDj4kfrqQ89G4qdWuWtVJAzDvFuOZ5w%40mail.gmail.com</a>.<br />
--001a11409dae8204af054c810245--
.
Author: Greg Marr <gregmmarr@gmail.com>
Date: Thu, 6 Apr 2017 08:23:34 -0700 (PDT)
Raw View
------=_Part_10678_876807850.1491492214973
Content-Type: multipart/alternative;
boundary="----=_Part_10679_1517739105.1491492214974"
------=_Part_10679_1517739105.1491492214974
Content-Type: text/plain; charset=UTF-8
On Thursday, April 6, 2017 at 11:12:25 AM UTC-4, Avi Kivity wrote:
>
> I'm sure this was suggested before, but couldn't find it on google:
>
This was discussed here about 6 months ago, including dgutson's "proposal".
https://groups.google.com/a/isocpp.org/forum/#!searchin/std-proposals/default/std-proposals/mxr5s9fz-Tk/Qkeww8cbBgAJ
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/189856f7-3503-464c-a17c-e01afa701ec6%40isocpp.org.
------=_Part_10679_1517739105.1491492214974
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, April 6, 2017 at 11:12:25 AM UTC-4, Avi Kivit=
y wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0=
..8ex;border-left: 1px #ccc solid;padding-left: 1ex;">I'm sure this was =
suggested before, but couldn't find it on google:
<br></blockquote><div><br></div><div>This was discussed here about 6 months=
ago, including dgutson's "proposal".</div><div><br></div><di=
v>https://groups.google.com/a/isocpp.org/forum/#!searchin/std-proposals/def=
ault/std-proposals/mxr5s9fz-Tk/Qkeww8cbBgAJ</div><div><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/189856f7-3503-464c-a17c-e01afa701ec6%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/189856f7-3503-464c-a17c-e01afa701ec6=
%40isocpp.org</a>.<br />
------=_Part_10679_1517739105.1491492214974--
------=_Part_10678_876807850.1491492214973--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Thu, 6 Apr 2017 08:26:55 -0700 (PDT)
Raw View
------=_Part_10056_1532829455.1491492415732
Content-Type: multipart/alternative;
boundary="----=_Part_10057_1749587752.1491492415732"
------=_Part_10057_1749587752.1491492415732
Content-Type: text/plain; charset=UTF-8
On Thursday, April 6, 2017 at 11:17:42 AM UTC-4, dgutson wrote:
>
> see the date:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1466.pdf
>
I'm with Stroustrup: "Nahh...don't complicate default parameters. We have
overloading instead."
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a39f277a-549f-4b4a-881b-09fd1cf4087e%40isocpp.org.
------=_Part_10057_1749587752.1491492415732
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, April 6, 2017 at 11:17:42 AM UTC-4, dgutson w=
rote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8e=
x;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">see the =
date: <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1=
466.pdf" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'=
;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22=
%2Fwg21%2Fdocs%2Fpapers%2F2003%2Fn1466.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x=
3dAFQjCNH6n-B7857cuj_lMr4yqOp36CJ-rg';return true;" onclick=3D"this.hre=
f=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.open-std.org%2Fjtc=
1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2003%2Fn1466.pdf\x26sa\x3dD\x26sntz\x3d1\=
x26usg\x3dAFQjCNH6n-B7857cuj_lMr4yqOp36CJ-rg';return true;">http://www.=
open-std.org/jtc1/<wbr>sc22/wg21/docs/papers/2003/<wbr>n1466.pdf</a></div><=
/blockquote><div><br>I'm with Stroustrup: "Nahh...don't compli=
cate default parameters. We have overloading instead."</div><br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a39f277a-549f-4b4a-881b-09fd1cf4087e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a39f277a-549f-4b4a-881b-09fd1cf4087e=
%40isocpp.org</a>.<br />
------=_Part_10057_1749587752.1491492415732--
------=_Part_10056_1532829455.1491492415732--
.
Author: Avi Kivity <avi@scylladb.com>
Date: Thu, 6 Apr 2017 19:28:29 +0300
Raw View
This is a multi-part message in MIME format.
--------------F008B757794F6FEB43BE47E1
Content-Type: text/plain; charset=UTF-8; format=flowed
On 04/06/2017 06:26 PM, Nicol Bolas wrote:
> On Thursday, April 6, 2017 at 11:17:42 AM UTC-4, dgutson wrote:
>
> see the date:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1466.pdf
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1466.pdf>
>
>
> I'm with Stroustrup: "Nahh...don't complicate default parameters. We
> have overloading instead."
>
>
How can I overload f(int = 1, int = 2, int = 3, int = 4) to allow any
combination of parameters to be overloaded?
Named arguments would be better though, but I understand that's dead
(and why).
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/23242c11-a20b-9dfe-42fc-7a1ae3195849%40scylladb.com.
--------------F008B757794F6FEB43BE47E1
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<p><br>
</p>
<br>
<div class=3D"moz-cite-prefix">On 04/06/2017 06:26 PM, Nicol Bolas
wrote:<br>
</div>
<blockquote
cite=3D"mid:a39f277a-549f-4b4a-881b-09fd1cf4087e@isocpp.org"
type=3D"cite">
<div dir=3D"ltr">On Thursday, April 6, 2017 at 11:17:42 AM UTC-4,
dgutson wrote:
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<div dir=3D"ltr">see the date: <a moz-do-not-send=3D"true"
href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/20=
03/n1466.pdf"
target=3D"_blank" rel=3D"nofollow"
onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww=
..open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2003%2Fn1466.pdf\x26sa=
\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH6n-B7857cuj_lMr4yqOp36CJ-rg';return
true;"
onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.ope=
n-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2003%2Fn1466.pdf\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNH6n-B7857cuj_lMr4yqOp36CJ-rg';return
true;">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/paper=
s/2003/<wbr>n1466.pdf</a></div>
</blockquote>
<div><br>
I'm with Stroustrup: "Nahh...don't complicate default
parameters. We have overloading instead."</div>
<br>
</div>
<br>
</blockquote>
<br>
<br>
How can I overload f(int =3D 1, int =3D 2, int =3D 3, int =3D 4) to all=
ow
any combination of parameters to be overloaded?<br>
<br>
Named arguments would be better though, but I understand that's dead
(and why).<br>
<br>
</body>
</html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/23242c11-a20b-9dfe-42fc-7a1ae3195849%=
40scylladb.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.googl=
e.com/a/isocpp.org/d/msgid/std-proposals/23242c11-a20b-9dfe-42fc-7a1ae31958=
49%40scylladb.com</a>.<br />
--------------F008B757794F6FEB43BE47E1--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Thu, 6 Apr 2017 09:44:00 -0700 (PDT)
Raw View
------=_Part_17534_549721267.1491497040668
Content-Type: multipart/alternative;
boundary="----=_Part_17535_607875828.1491497040669"
------=_Part_17535_607875828.1491497040669
Content-Type: text/plain; charset=UTF-8
On Thursday, April 6, 2017 at 12:28:33 PM UTC-4, Avi Kivity wrote:
>
>
>
> On 04/06/2017 06:26 PM, Nicol Bolas wrote:
>
> On Thursday, April 6, 2017 at 11:17:42 AM UTC-4, dgutson wrote:
>>
>> see the date:
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1466.pdf
>>
>
> I'm with Stroustrup: "Nahh...don't complicate default parameters. We have
> overloading instead."
>
> How can I overload f(int = 1, int = 2, int = 3, int = 4) to allow any
> combination of parameters to be overloaded?
>
> Named arguments would be better though, but I understand that's dead (and
> why).
>
But it's not dead. Designated initializers will apparently exist in C++20,
which gives you the effective equivalent of named parameters:
struct f_args
{
int a = 1; int b = 2; int c = 3; int d = 4;
};
void f(f_args args);
f({.b = 1});
Equally importantly... why do you *need* to give people all of this
complexity? If your function has that many arguments, and that many of them
have default values, and none of those parameters are more likely to be
defaulted than others, then it seems very likely that your function is
doing too much work or otherwise taking too many parameters.
Furthermore, can you provide a real-world example of a case where the user
using this feature would make the code less complex? And by that, I mean
less complex than just living with the limitation, not less complex than
jumping through a bunch of hoops to enforce it. I have a hard time
reading`some_func(default, value, value, default, value)` and understanding
what that function is doing.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/6ee7b168-7b23-4368-a587-1f4042903db9%40isocpp.org.
------=_Part_17535_607875828.1491497040669
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Thursday, April 6, 2017 at 12:28:33 PM UTC-4, A=
vi Kivity wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
=20
=20
=20
<div bgcolor=3D"#FFFFFF" text=3D"#000000">
<p><br>
</p>
<br>
<div>On 04/06/2017 06:26 PM, Nicol Bolas
wrote:<br>
</div>
<blockquote type=3D"cite">
<div dir=3D"ltr">On Thursday, April 6, 2017 at 11:17:42 AM UTC-4,
dgutson wrote:
<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8=
ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">see the date: <a href=3D"http://www.open-std.org=
/jtc1/sc22/wg21/docs/papers/2003/n1466.pdf" rel=3D"nofollow" target=3D"_bla=
nk" onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%=
2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2003%2Fn1466.p=
df\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH6n-B7857cuj_lMr4yqOp36CJ-rg'=
;;return true;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3d=
http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2003%2=
Fn1466.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH6n-B7857cuj_lMr4yqOp36C=
J-rg';return true;">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/pa=
pers/2003/<wbr>n1466.pdf</a></div>
</blockquote>
<div><br>
I'm with Stroustrup: "Nahh...don't complicate defaul=
t
parameters. We have overloading instead."</div>
=20
</div>
=20
</blockquote>
=20
How can I overload f(int =3D 1, int =3D 2, int =3D 3, int =3D 4) to all=
ow
any combination of parameters to be overloaded?<br>
<br>
Named arguments would be better though, but I understand that's dea=
d
(and why).<br></div></blockquote><div><br>But it's not dead. Design=
ated initializers will apparently exist in C++20, which gives you the effec=
tive equivalent of named parameters:<br><br><div style=3D"background-color:=
rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid;=
border-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code=
class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: =
#008;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> f_args<br></span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> a </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">1</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> b </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">2</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> c </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #06=
6;" class=3D"styled-by-prettify">3</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
d </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #066;" class=3D"styled-by-prettify">4</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> f</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">f_args=
args</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>f</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">({.</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">b </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;=
" class=3D"styled-by-prettify">1</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">});</span></div></code></div><br>Equally importantl=
y... why do you <i>need</i> to give people all of this complexity? If your =
function has that many arguments, and that many of them have default values=
, and none of those parameters are more likely to be defaulted than others,=
then it seems very likely that your function is doing too much work or oth=
erwise taking too many parameters.<br><br>Furthermore, can you provide a re=
al-world example of a case where the user using this feature would make the=
code less complex? And by that, I mean less complex than just living with =
the limitation, not less complex than jumping through a bunch of hoops to e=
nforce it. I have a hard time reading`some_func(default, value, value, defa=
ult, value)` and understanding what that function is doing.<br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/6ee7b168-7b23-4368-a587-1f4042903db9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6ee7b168-7b23-4368-a587-1f4042903db9=
%40isocpp.org</a>.<br />
------=_Part_17535_607875828.1491497040669--
------=_Part_17534_549721267.1491497040668--
.
Author: =?UTF-8?Q?Jos=C3=A9_Rodrigo?= <rodrigojose690@gmail.com>
Date: Thu, 6 Apr 2017 19:05:03 -0300
Raw View
--001a1143e2d07a12dc054c86b3d7
Content-Type: text/plain; charset=UTF-8
better is func( , ,17);
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAJe%2Baq815Gvrtzk3vNyJbiQF7ZksQFkdc7w9GwpJP-mMtFpGmQ%40mail.gmail.com.
--001a1143e2d07a12dc054c86b3d7
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra">better is func( , ,17);</div></=
div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAJe%2Baq815Gvrtzk3vNyJbiQF7ZksQFkdc7=
w9GwpJP-mMtFpGmQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAJe%2Baq815Gvr=
tzk3vNyJbiQF7ZksQFkdc7w9GwpJP-mMtFpGmQ%40mail.gmail.com</a>.<br />
--001a1143e2d07a12dc054c86b3d7--
.
Author: "dgutson ." <danielgutson@gmail.com>
Date: Thu, 6 Apr 2017 19:12:35 -0300
Raw View
--94eb2c19816e682433054c86ce67
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
void func(int, int, int);
void func(char*, float, int);
who you gonna call? (GB of course!)
On Thu, Apr 6, 2017 at 7:05 PM, Jos=C3=A9 Rodrigo <rodrigojose690@gmail.com=
>
wrote:
> better is func( , ,17);
>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/CAJe%2Baq815Gvrtzk3vNyJbiQF7ZksQFkd
> c7w9GwpJP-mMtFpGmQ%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAJe%2Baq81=
5Gvrtzk3vNyJbiQF7ZksQFkdc7w9GwpJP-mMtFpGmQ%40mail.gmail.com?utm_medium=3Dem=
ail&utm_source=3Dfooter>
> .
>
--=20
Who=E2=80=99s got the sweetest disposition?
One guess, that=E2=80=99s who?
Who=E2=80=99d 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?
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAFdMc-3PD1xyyL1z2X8dfHiSL-8Tx%2Bo9fdQBCyNHmYmJz=
yoOzg%40mail.gmail.com.
--94eb2c19816e682433054c86ce67
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">void func(int, int, int);<div>void func(char*, float, int)=
;</div><div><br></div><div>who you gonna call? =C2=A0(GB of course!)</div><=
/div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Thu, Apr =
6, 2017 at 7:05 PM, Jos=C3=A9 Rodrigo <span dir=3D"ltr"><<a href=3D"mail=
to:rodrigojose690@gmail.com" target=3D"_blank">rodrigojose690@gmail.com</a>=
></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0=
0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div =
class=3D"gmail_extra">better is func( , ,17);</div></div><span class=3D"">
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAJe%2Baq815Gvrtzk3vNyJbiQF7ZksQFkdc7=
w9GwpJP-mMtFpGmQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/st=
d-<wbr>proposals/CAJe%<wbr>2Baq815Gvrtzk3vNyJbiQF7ZksQFkd<wbr>c7w9GwpJP-mMt=
FpGmQ%40mail.<wbr>gmail.com</a>.<br>
</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br><div class=
=3D"gmail_signature" data-smartmail=3D"gmail_signature">Who=E2=80=99s got t=
he sweetest disposition?<br>One guess, that=E2=80=99s who?<br>Who=E2=80=99d=
never, ever start an argument?<br>Who never shows a bit of temperament?<br=
>Who's never wrong but always right?<br>Who'd never dream of starti=
ng a fight?<br>Who get stuck with all the bad luck? </div>
</div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAFdMc-3PD1xyyL1z2X8dfHiSL-8Tx%2Bo9fd=
QBCyNHmYmJzyoOzg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFdMc-3PD1xyyL=
1z2X8dfHiSL-8Tx%2Bo9fdQBCyNHmYmJzyoOzg%40mail.gmail.com</a>.<br />
--94eb2c19816e682433054c86ce67--
.
Author: =?UTF-8?Q?Jos=C3=A9_Rodrigo?= <rodrigojose690@gmail.com>
Date: Thu, 6 Apr 2017 20:12:31 -0300
Raw View
--001a1143e2d0c1e820054c87a4d6
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
same as above:
void func(int, int, int);
void func(int, int, char*);
func(4, 5); // 'compile time error'
2017-04-06 19:12 GMT-03:00 dgutson . <danielgutson@gmail.com>:
> void func(int, int, int);
> void func(char*, float, int);
>
> who you gonna call? (GB of course!)
>
> On Thu, Apr 6, 2017 at 7:05 PM, Jos=C3=A9 Rodrigo <rodrigojose690@gmail.c=
om>
> wrote:
>
>> better is func( , ,17);
>>
>> --
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> email to std-proposals+unsubscribe@isocpp.org.
>> To post to this group, send email to std-proposals@isocpp.org.
>> To view this discussion on the web visit https://groups.google.com/a/is
>> ocpp.org/d/msgid/std-proposals/CAJe%2Baq815Gvrtzk3vNyJbiQF7Z
>> ksQFkdc7w9GwpJP-mMtFpGmQ%40mail.gmail.com
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAJe%2Baq8=
15Gvrtzk3vNyJbiQF7ZksQFkdc7w9GwpJP-mMtFpGmQ%40mail.gmail.com?utm_medium=3De=
mail&utm_source=3Dfooter>
>> .
>>
>
>
>
> --
> Who=E2=80=99s got the sweetest disposition?
> One guess, that=E2=80=99s who?
> Who=E2=80=99d 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?
>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/CAFdMc-3PD1xyyL1z2X8dfHiSL-8Tx%
> 2Bo9fdQBCyNHmYmJzyoOzg%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFdMc-3PD1=
xyyL1z2X8dfHiSL-8Tx%2Bo9fdQBCyNHmYmJzyoOzg%40mail.gmail.com?utm_medium=3Dem=
ail&utm_source=3Dfooter>
> .
>
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAJe%2Baq-HG9osu%2BDosCO9rw58bNWi%3D3mCc39-%3D97=
mrnDTuA0cTQ%40mail.gmail.com.
--001a1143e2d0c1e820054c87a4d6
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>same as above:</div><div><span style=3D"font-size:12.=
8px">void func(int, int, int);</span></div><div style=3D"font-size:12.8px">=
void func(int, int, char*);=C2=A0</div><div style=3D"font-size:12.8px"><br>=
</div><div style=3D"font-size:12.8px">func(4, 5); //=C2=A0<span style=3D"fo=
nt-size:small">'compile time error'</span></div></div><div class=3D=
"gmail_extra"><br><div class=3D"gmail_quote">2017-04-06 19:12 GMT-03:00 dgu=
tson . <span dir=3D"ltr"><<a href=3D"mailto:danielgutson@gmail.com" targ=
et=3D"_blank">danielgutson@gmail.com</a>></span>:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div dir=3D"ltr">void func(int, int, int);<div>void func(char=
*, float, int);</div><div><br></div><div>who you gonna call? =C2=A0(GB of c=
ourse!)</div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote=
">On Thu, Apr 6, 2017 at 7:05 PM, Jos=C3=A9 Rodrigo <span dir=3D"ltr"><<=
a href=3D"mailto:rodrigojose690@gmail.com" target=3D"_blank">rodrigojose690=
@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr"><div class=3D"gmail_extra">better is func( , ,17);</div></div><spa=
n>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isoc<wbr>pp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAJe%2Baq815Gvrtzk3vNyJbiQF7ZksQFkdc7=
w9GwpJP-mMtFpGmQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/st=
d-proposals<wbr>/CAJe%2Baq815Gvrtzk3vNyJbiQF7Z<wbr>ksQFkdc7w9GwpJP-mMtFpGmQ=
%<wbr>40mail.gmail.com</a>.<span class=3D"HOEnZb"><font color=3D"#888888"><=
br>
</font></span></blockquote></div><span class=3D"HOEnZb"><font color=3D"#888=
888"><br><br clear=3D"all"><div><br></div>-- <br><div class=3D"m_-535799715=
7574086093gmail_signature" data-smartmail=3D"gmail_signature">Who=E2=80=99s=
got the sweetest disposition?<br>One guess, that=E2=80=99s who?<br>Who=E2=
=80=99d never, ever start an argument?<br>Who never shows a bit of temperam=
ent?<br>Who's never wrong but always right?<br>Who'd never dream of=
starting a fight?<br>Who get stuck with all the bad luck? </div>
</font></span></div><span class=3D"HOEnZb"><font color=3D"#888888">
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAFdMc-3PD1xyyL1z2X8dfHiSL-8Tx%2Bo9fd=
QBCyNHmYmJzyoOzg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/st=
d-<wbr>proposals/CAFdMc-<wbr>3PD1xyyL1z2X8dfHiSL-8Tx%<wbr>2Bo9fdQBCyNHmYmJz=
yoOzg%40mail.<wbr>gmail.com</a>.<br>
</font></span></blockquote></div><br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAJe%2Baq-HG9osu%2BDosCO9rw58bNWi%3D3=
mCc39-%3D97mrnDTuA0cTQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAJe%2Baq=
-HG9osu%2BDosCO9rw58bNWi%3D3mCc39-%3D97mrnDTuA0cTQ%40mail.gmail.com</a>.<br=
/>
--001a1143e2d0c1e820054c87a4d6--
.
Author: Avi Kivity <avi@scylladb.com>
Date: Fri, 7 Apr 2017 12:36:25 +0300
Raw View
This is a multi-part message in MIME format.
--------------13372B8BD8DCF0F697C29281
Content-Type: text/plain; charset=UTF-8; format=flowed
On 04/06/2017 07:44 PM, Nicol Bolas wrote:
>
>
> On Thursday, April 6, 2017 at 12:28:33 PM UTC-4, Avi Kivity wrote:
>
>
>
> On 04/06/2017 06:26 PM, Nicol Bolas wrote:
>> On Thursday, April 6, 2017 at 11:17:42 AM UTC-4, dgutson wrote:
>>
>> see the date:
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1466.pdf
>> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1466.pdf>
>>
>>
>> I'm with Stroustrup: "Nahh...don't complicate default parameters.
>> We have overloading instead."
> How can I overload f(int = 1, int = 2, int = 3, int = 4) to allow
> any combination of parameters to be overloaded?
>
> Named arguments would be better though, but I understand that's
> dead (and why).
>
>
> But it's not dead. Designated initializers will apparently exist in
> C++20, which gives you the effective equivalent of named parameters:
>
> |
> structf_args
> {
> inta =1;intb =2;intc =3;intd =4;
> };
>
> voidf(f_args args);
>
> f({.b =1});
> |
>
> Equally importantly... why do you /need/ to give people all of this
> complexity? If your function has that many arguments, and that many of
> them have default values, and none of those parameters are more likely
> to be defaulted than others, then it seems very likely that your
> function is doing too much work or otherwise taking too many parameters.
Sometimes functions are indeed complicated, and sometimes they evolve
this way. I hope C++ is not meant for perfect software only.
>
> Furthermore, can you provide a real-world example of a case where the
> user using this feature would make the code less complex? And by that,
> I mean less complex than just living with the limitation, not less
> complex than jumping through a bunch of hoops to enforce it. I have a
> hard time reading`some_func(default, value, value, default, value)`
> and understanding what that function is doing.
I too prefer a struct for passing large number of configuration items.
If we have designated initializers, then that's a superior solution to
the problem.
The typical pattern I see
start with a constructor with a few (maybe no) parameters
grow parameters overtime, defaulting them to preserve compatibility
give up in disgust and replace with a config struct, adding much
boilerplate to call sites
Designated initializers aren't perfect for this, but they're pretty good
(real named arguments would be better).
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/57ddf392-ae57-bfd2-1ae6-15da6fce5aa9%40scylladb.com.
--------------13372B8BD8DCF0F697C29281
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<div class=3D"moz-cite-prefix">On 04/06/2017 07:44 PM, Nicol Bolas
wrote:<br>
</div>
<blockquote
cite=3D"mid:6ee7b168-7b23-4368-a587-1f4042903db9@isocpp.org"
type=3D"cite">
<div dir=3D"ltr"><br>
<br>
On Thursday, April 6, 2017 at 12:28:33 PM UTC-4, Avi Kivity
wrote:
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<div bgcolor=3D"#FFFFFF" text=3D"#000000">
<p><br>
</p>
<br>
<div>On 04/06/2017 06:26 PM, Nicol Bolas wrote:<br>
</div>
<blockquote type=3D"cite">
<div dir=3D"ltr">On Thursday, April 6, 2017 at 11:17:42 AM
UTC-4, dgutson wrote:
<blockquote class=3D"gmail_quote"
style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div dir=3D"ltr">see the date: <a
moz-do-not-send=3D"true"
href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/p=
apers/2003/n1466.pdf"
rel=3D"nofollow" target=3D"_blank"
onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww=
..open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2003%2Fn1466.pdf\x26sa=
\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH6n-B7857cuj_lMr4yqOp36CJ-rg';return
true;"
onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.ope=
n-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2003%2Fn1466.pdf\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNH6n-B7857cuj_lMr4yqOp36CJ-rg';return
true;">http://www.open-std.org/jtc1/<wbr>sc22/wg21/do=
cs/papers/2003/<wbr>n1466.pdf</a></div>
</blockquote>
<div><br>
I'm with Stroustrup: "Nahh...don't complicate default
parameters. We have overloading instead."</div>
</div>
</blockquote>
How can I overload f(int =3D 1, int =3D 2, int =3D 3, int =3D 4=
) to
allow any combination of parameters to be overloaded?<br>
<br>
Named arguments would be better though, but I understand
that's dead (and why).<br>
</div>
</blockquote>
<div><br>
But it's not dead. Designated initializers will apparently
exist in C++20, which gives you the effective equivalent of
named parameters:<br>
<br>
<div style=3D"background-color: rgb(250, 250, 250);
border-color: rgb(187, 187, 187); border-style: solid;
border-width: 1px; overflow-wrap: break-word;"
class=3D"prettyprint"><code class=3D"prettyprint">
<div class=3D"subprettyprint"><span style=3D"color: #008;"
class=3D"styled-by-prettify">struct</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">
f_args<br>
</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">{</span><span style=3D"color=
:
#000;" class=3D"styled-by-prettify"><br>
=C2=A0 </span><span style=3D"color: #008;"
class=3D"styled-by-prettify">int</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> a </=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #066;" class=3D"styled-by-prettify">1</sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">int</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> b </=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #066;" class=3D"styled-by-prettify">2</sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">int</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> c </=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #066;" class=3D"styled-by-prettify">3</sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">int</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> d </=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #066;" class=3D"styled-by-prettify">4</sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">};</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
<br>
</span><span style=3D"color: #008;"
class=3D"styled-by-prettify">void</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> f</s=
pan><span
style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify">f_arg=
s
args</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">);</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
<br>
f</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">({.</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">b </s=
pan><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #066;" class=3D"styled-by-prettify">1</sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">});</=
span></div>
</code></div>
<br>
Equally importantly... why do you <i>need</i> to give people
all of this complexity? If your function has that many
arguments, and that many of them have default values, and none
of those parameters are more likely to be defaulted than
others, then it seems very likely that your function is doing
too much work or otherwise taking too many parameters.<br>
</div>
</div>
</blockquote>
<br>
Sometimes functions are indeed complicated, and sometimes they
evolve this way.=C2=A0 I hope C++ is not meant for perfect software onl=
y.<br>
<br>
<blockquote
cite=3D"mid:6ee7b168-7b23-4368-a587-1f4042903db9@isocpp.org"
type=3D"cite">
<div dir=3D"ltr">
<div><br>
Furthermore, can you provide a real-world example of a case
where the user using this feature would make the code less
complex? And by that, I mean less complex than just living
with the limitation, not less complex than jumping through a
bunch of hoops to enforce it. I have a hard time
reading`some_func(default, value, value, default, value)` and
understanding what that function is doing.<br>
</div>
</div>
</blockquote>
<br>
I too prefer a struct for passing large number of configuration
items.=C2=A0 If we have designated initializers, then that's a superior
solution to the problem.<br>
<br>
<br>
The typical pattern I see<br>
<br>
=C2=A0 start with a constructor with a few (maybe no) parameters<br>
=C2=A0 grow parameters overtime, defaulting them to preserve
compatibility<br>
=C2=A0 give up in disgust and replace with a config struct, adding much
boilerplate to call sites<br>
<br>
Designated initializers aren't perfect for this, but they're pretty
good (real named arguments would be better).<br>
<br>
</body>
</html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/57ddf392-ae57-bfd2-1ae6-15da6fce5aa9%=
40scylladb.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.googl=
e.com/a/isocpp.org/d/msgid/std-proposals/57ddf392-ae57-bfd2-1ae6-15da6fce5a=
a9%40scylladb.com</a>.<br />
--------------13372B8BD8DCF0F697C29281--
.
Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Fri, 7 Apr 2017 16:09:03 -0700 (PDT)
Raw View
------=_Part_179_1065944402.1491606543178
Content-Type: multipart/alternative;
boundary="----=_Part_180_1257962093.1491606543179"
------=_Part_180_1257962093.1491606543179
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Thursday, April 6, 2017 at 9:28:33 AM UTC-7, Avi Kivity wrote:
>
> On 04/06/2017 06:26 PM, Nicol Bolas wrote:
>
> On Thursday, April 6, 2017 at 11:17:42 AM UTC-4, dgutson wrote:=20
>>
>> see the date:=20
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1466.pdf
>>
>
> I'm with Stroustrup: "Nahh...don't complicate default parameters. We have=
=20
> overloading instead."
>
>
> How can I overload f(int =3D 1, int =3D 2, int =3D 3, int =3D 4) to allow=
any=20
> combination of parameters to be overloaded?
>
You might look into how Boost does it with boost::use_default. I haven't=20
looked myself and can't promise anything, but I gather that several Boost=
=20
libraries have something like this:
inline struct use_default_t {} use_default;
template<class T, T default_value> struct defaulted {
optional<T> value;
defaulted(T);
defaulted(use_default_t);
operator T() const;
};
void f(defaulted<int, 1> a, defaulted<int, 2> b, defaulted<int, 3> c,=20
defaulted<int, 4> d);
auto x =3D f(42, use_default, 43, use_default);
Obviously the way I wrote it works only for literal types; but you can=20
imagine how to "do it right" if you really needed this functionality in a=
=20
library of your own.
If you go too far down the path of runtime-ness and customizability, I=20
think you end up with std::optional<T> anyway, so maybe the standard *does*=
=20
provide exactly what you'll end up wanting anyway. ;)
=E2=80=93Arthur
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/d3ef1ce9-062d-4cb1-8001-0255edc86076%40isocpp.or=
g.
------=_Part_180_1257962093.1491606543179
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, April 6, 2017 at 9:28:33 AM UTC-7, Avi Kivity=
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
=20
=20
=20
<div bgcolor=3D"#FFFFFF" text=3D"#000000">
<p>On 04/06/2017 06:26 PM, Nicol Bolas
wrote:<br></p>
<blockquote type=3D"cite">
<div dir=3D"ltr">On Thursday, April 6, 2017 at 11:17:42 AM UTC-4,
dgutson wrote:
<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8=
ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">see the date: <a href=3D"http://www.open-std.org=
/jtc1/sc22/wg21/docs/papers/2003/n1466.pdf" rel=3D"nofollow" target=3D"_bla=
nk" onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%=
2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2003%2Fn1466.p=
df\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH6n-B7857cuj_lMr4yqOp36CJ-rg'=
;;return true;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3d=
http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2003%2=
Fn1466.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH6n-B7857cuj_lMr4yqOp36C=
J-rg';return true;">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/pa=
pers/2003/<wbr>n1466.pdf</a></div>
</blockquote>
<div><br>
I'm with Stroustrup: "Nahh...don't complicate defaul=
t
parameters. We have overloading instead."</div>
</div></blockquote><br>
How can I overload f(int =3D 1, int =3D 2, int =3D 3, int =3D 4) to all=
ow
any combination of parameters to be overloaded?<br></div></blockquote><=
div><br></div><div>You might look into how Boost does it with boost::use_de=
fault. I haven't looked myself and can't promise anything, but I ga=
ther that several Boost libraries have something like this:</div><div><br><=
/div><div><font face=3D"courier new, monospace">inline struct use_default_t=
{} use_default;</font></div><div><font face=3D"courier new, monospace">tem=
plate<class T, T default_value> struct defaulted {</font></div><div><=
font face=3D"courier new, monospace">=C2=A0 optional<T> value;</font>=
</div><div><font face=3D"courier new, monospace">=C2=A0 defaulted(T);</font=
></div><div><font face=3D"courier new, monospace">=C2=A0 defaulted(use_defa=
ult_t);</font></div><div><font face=3D"courier new, monospace">=C2=A0 opera=
tor T() const;</font></div><div><font face=3D"courier new, monospace">};</f=
ont></div><div><font face=3D"courier new, monospace"><br></font></div><div>=
<font face=3D"courier new, monospace">void f(defaulted<int, 1> a, def=
aulted<int, 2> b, defaulted<int, 3> c, defaulted<int, 4> =
d);<br></font></div><div><font face=3D"courier new, monospace"><br></font><=
/div><div><font face=3D"courier new, monospace">auto x =3D f(42, use_defaul=
t, 43, use_default);</font></div><div><br></div><div>Obviously the way I wr=
ote it works only for literal types; but you can imagine how to "do it=
right" if you really needed this functionality in a library of your o=
wn.</div><div>If you go too far down the path of runtime-ness and customiza=
bility, I think you end up with std::optional<T> anyway, so maybe the=
standard *does* provide exactly what you'll end up wanting anyway. ;)<=
/div><div><br></div><div>=E2=80=93Arthur</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/d3ef1ce9-062d-4cb1-8001-0255edc86076%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d3ef1ce9-062d-4cb1-8001-0255edc86076=
%40isocpp.org</a>.<br />
------=_Part_180_1257962093.1491606543179--
------=_Part_179_1065944402.1491606543178--
.
Author: Avi Kivity <avi@scylladb.com>
Date: Mon, 10 Apr 2017 13:34:48 +0300
Raw View
This is a multi-part message in MIME format.
--------------7FA68456636F9F1E50192CA0
Content-Type: text/plain; charset=UTF-8; format=flowed
On 04/08/2017 02:09 AM, Arthur O'Dwyer wrote:
> On Thursday, April 6, 2017 at 9:28:33 AM UTC-7, Avi Kivity wrote:
>
> On 04/06/2017 06:26 PM, Nicol Bolas wrote:
>
>> On Thursday, April 6, 2017 at 11:17:42 AM UTC-4, dgutson wrote:
>>
>> see the date:
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1466.pdf
>> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1466.pdf>
>>
>>
>> I'm with Stroustrup: "Nahh...don't complicate default parameters.
>> We have overloading instead."
>
> How can I overload f(int = 1, int = 2, int = 3, int = 4) to allow
> any combination of parameters to be overloaded?
>
>
> You might look into how Boost does it with boost::use_default. I
> haven't looked myself and can't promise anything, but I gather that
> several Boost libraries have something like this:
>
> inline struct use_default_t {} use_default;
> template<class T, T default_value> struct defaulted {
> optional<T> value;
> defaulted(T);
> defaulted(use_default_t);
> operator T() const;
> };
>
> void f(defaulted<int, 1> a, defaulted<int, 2> b, defaulted<int, 3> c,
> defaulted<int, 4> d);
>
> auto x = f(42, use_default, 43, use_default);
>
> Obviously the way I wrote it works only for literal types; but you can
> imagine how to "do it right" if you really needed this functionality
> in a library of your own.
> If you go too far down the path of runtime-ness and customizability, I
> think you end up with std::optional<T> anyway, so maybe the standard
> *does* provide exactly what you'll end up wanting anyway. ;)
>
>
While using std::optional (or defaulted) is verbose, I don't think
there's enough value in the proposal to justify a language change.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/63eeacfa-ed6e-208b-fa4b-69a659718382%40scylladb.com.
--------------7FA68456636F9F1E50192CA0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8=
">
</head>
<body text=3D"#000000" bgcolor=3D"#FFFFFF">
<p><br>
</p>
<br>
<div class=3D"moz-cite-prefix">On 04/08/2017 02:09 AM, Arthur O'Dwyer
wrote:<br>
</div>
<blockquote type=3D"cite"
cite=3D"mid:d3ef1ce9-062d-4cb1-8001-0255edc86076@isocpp.org">
<div dir=3D"ltr">On Thursday, April 6, 2017 at 9:28:33 AM UTC-7, Avi
Kivity wrote:
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<div bgcolor=3D"#FFFFFF" text=3D"#000000">
<p>On 04/06/2017 06:26 PM, Nicol Bolas wrote:<br>
</p>
<blockquote type=3D"cite">
<div dir=3D"ltr">On Thursday, April 6, 2017 at 11:17:42 AM
UTC-4, dgutson wrote:
<blockquote class=3D"gmail_quote"
style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div dir=3D"ltr">see the date: <a
href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/p=
apers/2003/n1466.pdf"
rel=3D"nofollow" target=3D"_blank"
onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww=
..open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2003%2Fn1466.pdf\x26sa=
\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH6n-B7857cuj_lMr4yqOp36CJ-rg';return
true;"
onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.ope=
n-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2003%2Fn1466.pdf\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNH6n-B7857cuj_lMr4yqOp36CJ-rg';return
true;" moz-do-not-send=3D"true">http://www.open-std.o=
rg/jtc1/<wbr>sc22/wg21/docs/papers/2003/<wbr>n1466.pdf</a></div>
</blockquote>
<div><br>
I'm with Stroustrup: "Nahh...don't complicate default
parameters. We have overloading instead."</div>
</div>
</blockquote>
<br>
How can I overload f(int =3D 1, int =3D 2, int =3D 3, int =3D 4=
) to
allow any combination of parameters to be overloaded?<br>
</div>
</blockquote>
<div><br>
</div>
<div>You might look into how Boost does it with
boost::use_default. I haven't looked myself and can't promise
anything, but I gather that several Boost libraries have
something like this:</div>
<div><br>
</div>
<div><font face=3D"courier new, monospace">inline struct
use_default_t {} use_default;</font></div>
<div><font face=3D"courier new, monospace">template<class T, T
default_value> struct defaulted {</font></div>
<div><font face=3D"courier new, monospace">=C2=A0 optional<T>
value;</font></div>
<div><font face=3D"courier new, monospace">=C2=A0 defaulted(T);</fo=
nt></div>
<div><font face=3D"courier new, monospace">=C2=A0
defaulted(use_default_t);</font></div>
<div><font face=3D"courier new, monospace">=C2=A0 operator T() cons=
t;</font></div>
<div><font face=3D"courier new, monospace">};</font></div>
<div><font face=3D"courier new, monospace"><br>
</font></div>
<div><font face=3D"courier new, monospace">void
f(defaulted<int, 1> a, defaulted<int, 2> b,
defaulted<int, 3> c, defaulted<int, 4> d);<br>
</font></div>
<div><font face=3D"courier new, monospace"><br>
</font></div>
<div><font face=3D"courier new, monospace">auto x =3D f(42,
use_default, 43, use_default);</font></div>
<div><br>
</div>
<div>Obviously the way I wrote it works only for literal types;
but you can imagine how to "do it right" if you really needed
this functionality in a library of your own.</div>
<div>If you go too far down the path of runtime-ness and
customizability, I think you end up with
std::optional<T> anyway, so maybe the standard *does*
provide exactly what you'll end up wanting anyway. ;)</div>
<div><br>
</div>
<br>
</div>
</blockquote>
<br>
While using std::optional (or defaulted) is verbose, I don't think
there's enough value in the proposal to justify a language change.<br>
</body>
</html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/63eeacfa-ed6e-208b-fa4b-69a659718382%=
40scylladb.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.googl=
e.com/a/isocpp.org/d/msgid/std-proposals/63eeacfa-ed6e-208b-fa4b-69a6597183=
82%40scylladb.com</a>.<br />
--------------7FA68456636F9F1E50192CA0--
.
Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Mon, 10 Apr 2017 11:36:59 -0400
Raw View
On 2017-04-07 19:09, Arthur O'Dwyer wrote:
> You might look into how Boost does it with boost::use_default. I haven't
> looked myself and can't promise anything, but I gather that several Boost
> libraries have something like this:
>
> inline struct use_default_t {} use_default;
> template<class T, T default_value> struct defaulted {
> optional<T> value;
> defaulted(T);
> defaulted(use_default_t);
> operator T() const;
> };
>
> void f(defaulted<int, 1> a, defaulted<int, 2> b, defaulted<int, 3> c,
> defaulted<int, 4> d);
Ugh; you've promoted changing the default from a SIC to a BIC.
OTOH, if you use `optional<T>=nullopt` as a replacement for defaulted
parameters, you can change the default *without* breaking SC, albeit at
a run-time cost.
--
Matthew
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/58EBA69B.2020902%40gmail.com.
.
Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Mon, 10 Apr 2017 20:10:16 -0700 (PDT)
Raw View
------=_Part_13617_1479685104.1491880216159
Content-Type: multipart/alternative;
boundary="----=_Part_13618_2003694291.1491880216159"
------=_Part_13618_2003694291.1491880216159
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Monday, April 10, 2017 at 8:37:03 AM UTC-7, Matthew Woehlke wrote:
>
> On 2017-04-07 19:09, Arthur O'Dwyer wrote:=20
> > You might look into how Boost does it with boost::use_default. I haven'=
t=20
> > looked myself and can't promise anything, but I gather that several=20
> Boost=20
> > libraries have something like this:=20
> >=20
> > inline struct use_default_t {} use_default;=20
> > template<class T, T default_value> struct defaulted {=20
> > optional<T> value;=20
> > defaulted(T);=20
> > defaulted(use_default_t);=20
> > operator T() const;=20
> > };=20
> >=20
> > void f(defaulted<int, 1> a, defaulted<int, 2> b, defaulted<int, 3> c,=
=20
> > defaulted<int, 4> d);=20
>
> Ugh; you've promoted changing the default from a SIC to a BIC.=20
>
(I guess "SIC"=3D"syntactic interface change" and "BIC"=3D"binary interface=
=20
change". Consider spelling these abbreviations out on first reference.)
=20
> OTOH, if you use `optional<T>=3Dnullopt` as a replacement for defaulted=
=20
> parameters, you can change the default *without* breaking SC, albeit at=
=20
> a run-time cost.=20
>
Right.
=E2=80=93Arthur
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/fb7458cb-d28c-4625-8a90-0a89b05a3622%40isocpp.or=
g.
------=_Part_13618_2003694291.1491880216159
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Monday, April 10, 2017 at 8:37:03 AM UTC-7, Matthew Woe=
hlke wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left=
: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 2017-04-07 19:09=
, Arthur O'Dwyer wrote:
<br>> You might look into how Boost does it with boost::use_default. I h=
aven't=20
<br>> looked myself and can't promise anything, but I gather that se=
veral Boost=20
<br>> libraries have something like this:
<br>>=20
<br>> inline struct use_default_t {} use_default;
<br>> template<class T, T default_value> struct defaulted {
<br>> =C2=A0 optional<T> value;
<br>> =C2=A0 defaulted(T);
<br>> =C2=A0 defaulted(use_default_t);
<br>> =C2=A0 operator T() const;
<br>> };
<br>>=20
<br>> void f(defaulted<int, 1> a, defaulted<int, 2> b, defau=
lted<int, 3> c,=20
<br>> defaulted<int, 4> d);
<br>
<br>Ugh; you've promoted changing the default from a SIC to a BIC.
<br></blockquote><div><br></div><div>(I guess "SIC"=3D"synta=
ctic interface change" and "BIC"=3D"binary interface ch=
ange". Consider spelling these abbreviations out on first reference.)<=
/div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">OTOH, if=
you use `optional<T>=3Dnullopt` as a replacement for defaulted
<br>parameters, you can change the default *without* breaking SC, albeit at
<br>a run-time cost.
<br></blockquote><div><br></div><div>Right.</div><div><br></div><div>=E2=80=
=93Arthur</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/fb7458cb-d28c-4625-8a90-0a89b05a3622%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/fb7458cb-d28c-4625-8a90-0a89b05a3622=
%40isocpp.org</a>.<br />
------=_Part_13618_2003694291.1491880216159--
------=_Part_13617_1479685104.1491880216159--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Mon, 10 Apr 2017 23:20:26 -0700
Raw View
Em segunda-feira, 10 de abril de 2017, =C3=A0s 20:10:16 PDT, Arthur O'Dwyer=
=20
escreveu:
> > Ugh; you've promoted changing the default from a SIC to a BIC.
>=20
> (I guess "SIC"=3D"syntactic interface change" and "BIC"=3D"binary interfa=
ce
> change". Consider spelling these abbreviations out on first reference.)
Source-Incompatible Change and Binary-Incompatible Change
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/15384811.ZevXnAStkh%40tjmaciei-mobl1.
.
Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Tue, 11 Apr 2017 10:22:13 -0400
Raw View
On 2017-04-10 23:10, Arthur O'Dwyer wrote:
> On Monday, April 10, 2017 at 8:37:03 AM UTC-7, Matthew Woehlke wrote:
>> On 2017-04-07 19:09, Arthur O'Dwyer wrote:=20
>>> You might look into how Boost does it with boost::use_default. I=20
>>> haven't looked myself and can't promise anything, but I gather
>>> that several Boost libraries have something like this:
>>>
>>> inline struct use_default_t {} use_default;=20
>>> template<class T, T default_value> struct defaulted {=20
>>> optional<T> value;=20
>>> defaulted(T);=20
>>> defaulted(use_default_t);=20
>>> operator T() const;=20
>>> };=20
>>>
>>> void f(defaulted<int, 1> a, defaulted<int, 2> b, defaulted<int, 3> c,=
=20
>>> defaulted<int, 4> d);=20
>>
>> Ugh; you've promoted changing the default from a SIC to a BIC.=20
>=20
> (I guess "SIC"=3D"syntactic interface change" and "BIC"=3D"binary interfa=
ce=20
> change". Consider spelling these abbreviations out on first reference.)
Anyone that has ever read qt-devel knows these. Alas, Google is
unusually unhelpful here.
SIC =E2=86=92 Source Incompatible Change
BIC =E2=86=92 Binary Incompatible Change
(There are also SC and BC =E2=86=92 Source/Binary Compatible.)
Actually, I realize that's slightly wrong. Changing a "normal" default
means that the code will still run, but recompiling will change the
behavior, so while it's technically both SC and BC, it is (potentially)
behavior breaking. (If done carefully, however, it can be okay to make
such a change.) Changing a "boost style default" not only (maybe)
changes behavior when the program is recompiled, it *is* an actual BIC,
i.e. your program will crash until it is recompiled because the ABI changed=
..
That makes it hard to argue that the above technique is an
"improvement". (There is an argument that the breakage alerts users to
the behavior change, but since it is SC, it's easy to miss if the
program gets rebuilt for some other reason.)
--=20
Matthew
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/58ECE695.8060601%40gmail.com.
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Tue, 11 Apr 2017 08:57:27 -0700 (PDT)
Raw View
------=_Part_2203_1057438781.1491926247562
Content-Type: multipart/alternative;
boundary="----=_Part_2204_348907761.1491926247562"
------=_Part_2204_348907761.1491926247562
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Tuesday, April 11, 2017 at 10:22:16 AM UTC-4, Matthew Woehlke wrote:
>
> On 2017-04-10 23:10, Arthur O'Dwyer wrote:=20
> > On Monday, April 10, 2017 at 8:37:03 AM UTC-7, Matthew Woehlke wrote:=
=20
> >> On 2017-04-07 19:09, Arthur O'Dwyer wrote:=20
> >>> You might look into how Boost does it with boost::use_default. I=20
> >>> haven't looked myself and can't promise anything, but I gather=20
> >>> that several Boost libraries have something like this:=20
> >>>=20
> >>> inline struct use_default_t {} use_default;=20
> >>> template<class T, T default_value> struct defaulted {=20
> >>> optional<T> value;=20
> >>> defaulted(T);=20
> >>> defaulted(use_default_t);=20
> >>> operator T() const;=20
> >>> };=20
> >>>=20
> >>> void f(defaulted<int, 1> a, defaulted<int, 2> b, defaulted<int, 3> c,=
=20
> >>> defaulted<int, 4> d);=20
> >>=20
> >> Ugh; you've promoted changing the default from a SIC to a BIC.=20
> >=20
> > (I guess "SIC"=3D"syntactic interface change" and "BIC"=3D"binary inter=
face=20
> > change". Consider spelling these abbreviations out on first reference.)=
=20
>
> Anyone that has ever read qt-devel knows these. Alas, Google is=20
> unusually unhelpful here.=20
>
> SIC =E2=86=92 Source Incompatible Change=20
> BIC =E2=86=92 Binary Incompatible Change=20
>
> (There are also SC and BC =E2=86=92 Source/Binary Compatible.)=20
>
> Actually, I realize that's slightly wrong. Changing a "normal" default=20
> means that the code will still run, but recompiling will change the=20
> behavior, so while it's technically both SC and BC, it is (potentially)=
=20
> behavior breaking. (If done carefully, however, it can be okay to make=20
> such a change.) Changing a "boost style default" not only (maybe)=20
> changes behavior when the program is recompiled, it *is* an actual BIC,=
=20
> i.e. your program will crash until it is recompiled because the ABI=20
> changed.=20
>
If default arguments are going to be made more complicated, then I would=20
genuinely want them to become part of the function's ABI. The current=20
situation, where they're just a bit of syntacitc sugar, is fine for the=20
simplest of cases. But when you get function calls like `func(default,=20
value, value2, default, value3)`, I think it's really important that if=20
that interface changes, everyone who call the function with them will need=
=20
to be recompiled.
That's why I think using named parameters via designated initilizers is=20
really the way to go to get this behavior.
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/a08da561-78d7-4dfe-8b22-d03b9b933ebe%40isocpp.or=
g.
------=_Part_2204_348907761.1491926247562
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Tuesday, April 11, 2017 at 10:22:16 AM UTC-4, Matthew W=
oehlke wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 2017-04-10 23:=
10, Arthur O'Dwyer wrote:
<br>> On Monday, April 10, 2017 at 8:37:03 AM UTC-7, Matthew Woehlke wro=
te:
<br>>> On 2017-04-07 19:09, Arthur O'Dwyer wrote:=20
<br>>>> You might look into how Boost does it with boost::use_defa=
ult. I=20
<br>>>> haven't looked myself and can't promise anything, =
but I gather
<br>>>> that several Boost libraries have something like this:
<br>>>>
<br>>>> inline struct use_default_t {} use_default;=20
<br>>>> template<class T, T default_value> struct defaulted =
{=20
<br>>>> =C2=A0 optional<T> value;=20
<br>>>> =C2=A0 defaulted(T);=20
<br>>>> =C2=A0 defaulted(use_default_t);=20
<br>>>> =C2=A0 operator T() const;=20
<br>>>> };=20
<br>>>>
<br>>>> void f(defaulted<int, 1> a, defaulted<int, 2> =
b, defaulted<int, 3> c,=20
<br>>>> defaulted<int, 4> d);=20
<br>>>
<br>>> Ugh; you've promoted changing the default from a SIC to a =
BIC.=20
<br>>=20
<br>> (I guess "SIC"=3D"syntactic interface change" =
and "BIC"=3D"binary interface=20
<br>> change". Consider spelling these abbreviations out on first r=
eference.)
<br>
<br>Anyone that has ever read qt-devel knows these. Alas, Google is
<br>unusually unhelpful here.
<br>
<br>SIC =E2=86=92 Source Incompatible Change
<br>BIC =E2=86=92 Binary Incompatible Change
<br>
<br>(There are also SC and BC =E2=86=92 Source/Binary Compatible.)
<br>
<br>Actually, I realize that's slightly wrong. Changing a "normal&=
quot; default
<br>means that the code will still run, but recompiling will change the
<br>behavior, so while it's technically both SC and BC, it is (potentia=
lly)
<br>behavior breaking. (If done carefully, however, it can be okay to make
<br>such a change.) Changing a "boost style default" not only (ma=
ybe)
<br>changes behavior when the program is recompiled, it *is* an actual BIC,
<br>i.e. your program will crash until it is recompiled because the ABI cha=
nged.
<br></blockquote><div><br>If default arguments are going to be made more co=
mplicated, then I would genuinely want them to become part of the function&=
#39;s ABI. The current situation, where they're just a bit of syntacitc=
sugar, is fine for the simplest of cases. But when you get function calls =
like `func(default, value, value2, default, value3)`, I think it's real=
ly important that if that interface changes, everyone who call the function=
with them will need to be recompiled.<br><br>That's why I think using =
named parameters via designated initilizers is really the way to go to get =
this behavior.<br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a08da561-78d7-4dfe-8b22-d03b9b933ebe%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a08da561-78d7-4dfe-8b22-d03b9b933ebe=
%40isocpp.org</a>.<br />
------=_Part_2204_348907761.1491926247562--
------=_Part_2203_1057438781.1491926247562--
.
Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Tue, 11 Apr 2017 12:50:42 -0400
Raw View
On 2017-04-11 11:57, Nicol Bolas wrote:
> If default arguments are going to be made more complicated, then I would
> genuinely want them to become part of the function's ABI. The current
> situation, where they're just a bit of syntacitc sugar, is fine for the
> simplest of cases. But when you get function calls like `func(default,
> value, value2, default, value3)`, I think it's really important that if
> that interface changes, everyone who call the function with them will need
> to be recompiled.
An ABI change means that any library with compatibility promises can
never change the defaults, whereas now they can (if the caveat that
not-recompiled code to use the old value is acceptable to such
compatibility promises).
> That's why I think using named parameters via designated initilizers is
> really the way to go to get this behavior.
....but that also won't change the ABI when the defaults change.
In both cases, code that is not recompiled continues to get the old
value, and will silently switch to the new value when recompiled.
--
Matthew
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/58ED0962.5070900%40gmail.com.
.
Author: "dgutson ." <danielgutson@gmail.com>
Date: Tue, 11 Apr 2017 23:43:41 -0300
Raw View
--001a1147e8c42d3949054cef2d8b
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
El 11/4/2017 12:57, "Nicol Bolas" <jmckesson@gmail.com> escribi=C3=B3:
On Tuesday, April 11, 2017 at 10:22:16 AM UTC-4, Matthew Woehlke wrote:
>
> On 2017-04-10 23:10, Arthur O'Dwyer wrote:
> > On Monday, April 10, 2017 at 8:37:03 AM UTC-7, Matthew Woehlke wrote:
> >> On 2017-04-07 19:09, Arthur O'Dwyer wrote:
> >>> You might look into how Boost does it with boost::use_default. I
> >>> haven't looked myself and can't promise anything, but I gather
> >>> that several Boost libraries have something like this:
> >>>
> >>> inline struct use_default_t {} use_default;
> >>> template<class T, T default_value> struct defaulted {
> >>> optional<T> value;
> >>> defaulted(T);
> >>> defaulted(use_default_t);
> >>> operator T() const;
> >>> };
> >>>
> >>> void f(defaulted<int, 1> a, defaulted<int, 2> b, defaulted<int, 3> c,
> >>> defaulted<int, 4> d);
> >>
> >> Ugh; you've promoted changing the default from a SIC to a BIC.
> >
> > (I guess "SIC"=3D"syntactic interface change" and "BIC"=3D"binary inter=
face
> > change". Consider spelling these abbreviations out on first reference.)
>
> Anyone that has ever read qt-devel knows these. Alas, Google is
> unusually unhelpful here.
>
> SIC =E2=86=92 Source Incompatible Change
> BIC =E2=86=92 Binary Incompatible Change
>
> (There are also SC and BC =E2=86=92 Source/Binary Compatible.)
>
> Actually, I realize that's slightly wrong. Changing a "normal" default
> means that the code will still run, but recompiling will change the
> behavior, so while it's technically both SC and BC, it is (potentially)
> behavior breaking. (If done carefully, however, it can be okay to make
> such a change.) Changing a "boost style default" not only (maybe)
> changes behavior when the program is recompiled, it *is* an actual BIC,
> i.e. your program will crash until it is recompiled because the ABI
> changed.
>
If default arguments are going to be made more complicated, then I would
genuinely want them to become part of the function's ABI. The current
situation, where they're just a bit of syntacitc sugar, is fine for the
simplest of cases. But when you get function calls like `func(default,
value, value2, default, value3)`, I think it's really important that if
that interface changes, everyone who call the function with them will need
to be recompiled.
Quite off topic but still relevant and familiar: I do prefer to solve
default template arguments than function arguments.
Many times I found myself trying to see what type of allocator or whatever
defsult template argument was used in order to specify the next one.
The trivial useless case, *just* to be illustrative:
unordered_map<Key, T, default, myAllocator>.
That's why I think using named parameters via designated initilizers is
really the way to go to get this behavior.
--=20
You received this message because you are subscribed to the Google Groups
"ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/
isocpp.org/d/msgid/std-proposals/a08da561-78d7-4dfe-
8b22-d03b9b933ebe%40isocpp.org
<https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a08da561-78d7=
-4dfe-8b22-d03b9b933ebe%40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter=
>
..
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAFdMc-1qSOjSpsDkG0n64k%2B%3Dngj85cFPpqaYg5%3DKZ=
mK1Yx5BQQ%40mail.gmail.com.
--001a1147e8c42d3949054cef2d8b
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"auto"><div><br><div class=3D"gmail_extra"><br><div class=3D"gma=
il_quote">El 11/4/2017 12:57, "Nicol Bolas" <<a href=3D"mailto=
:jmckesson@gmail.com">jmckesson@gmail.com</a>> escribi=C3=B3:<br type=3D=
"attribution"><blockquote class=3D"quote" style=3D"margin:0 0 0 .8ex;border=
-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"elide=
d-text">On Tuesday, April 11, 2017 at 10:22:16 AM UTC-4, Matthew Woehlke wr=
ote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;b=
order-left:1px #ccc solid;padding-left:1ex">On 2017-04-10 23:10, Arthur O&#=
39;Dwyer wrote:
<br>> On Monday, April 10, 2017 at 8:37:03 AM UTC-7, Matthew Woehlke wro=
te:
<br>>> On 2017-04-07 19:09, Arthur O'Dwyer wrote:=20
<br>>>> You might look into how Boost does it with boost::use_defa=
ult. I=20
<br>>>> haven't looked myself and can't promise anything, =
but I gather
<br>>>> that several Boost libraries have something like this:
<br>>>>
<br>>>> inline struct use_default_t {} use_default;=20
<br>>>> template<class T, T default_value> struct defaulted =
{=20
<br>>>> =C2=A0 optional<T> value;=20
<br>>>> =C2=A0 defaulted(T);=20
<br>>>> =C2=A0 defaulted(use_default_t);=20
<br>>>> =C2=A0 operator T() const;=20
<br>>>> };=20
<br>>>>
<br>>>> void f(defaulted<int, 1> a, defaulted<int, 2> =
b, defaulted<int, 3> c,=20
<br>>>> defaulted<int, 4> d);=20
<br>>>
<br>>> Ugh; you've promoted changing the default from a SIC to a =
BIC.=20
<br>>=20
<br>> (I guess "SIC"=3D"syntactic interface change" =
and "BIC"=3D"binary interface=20
<br>> change". Consider spelling these abbreviations out on first r=
eference.)
<br>
<br>Anyone that has ever read qt-devel knows these. Alas, Google is
<br>unusually unhelpful here.
<br>
<br>SIC =E2=86=92 Source Incompatible Change
<br>BIC =E2=86=92 Binary Incompatible Change
<br>
<br>(There are also SC and BC =E2=86=92 Source/Binary Compatible.)
<br>
<br>Actually, I realize that's slightly wrong. Changing a "normal&=
quot; default
<br>means that the code will still run, but recompiling will change the
<br>behavior, so while it's technically both SC and BC, it is (potentia=
lly)
<br>behavior breaking. (If done carefully, however, it can be okay to make
<br>such a change.) Changing a "boost style default" not only (ma=
ybe)
<br>changes behavior when the program is recompiled, it *is* an actual BIC,
<br>i.e. your program will crash until it is recompiled because the ABI cha=
nged.
<br></blockquote></div><div><br>If default arguments are going to be made m=
ore complicated, then I would genuinely want them to become part of the fun=
ction's ABI. The current situation, where they're just a bit of syn=
tacitc sugar, is fine for the simplest of cases. But when you get function =
calls like `func(default, value, value2, default, value3)`, I think it'=
s really important that if that interface changes, everyone who call the fu=
nction with them will need to be recompiled.<br></div></div></blockquote></=
div></div></div><div dir=3D"auto"><br></div><div dir=3D"auto">Quite off top=
ic but still relevant and familiar: I do prefer to solve default template a=
rguments than function arguments.</div><div dir=3D"auto">Many times I found=
myself trying to see what type of allocator or whatever defsult template a=
rgument was used in order to specify the next one.</div><div dir=3D"auto">T=
he trivial useless case, *just* to be illustrative:</div><div dir=3D"auto">=
=C2=A0 =C2=A0 unordered_map<Key, T, default, myAllocator>.</div><div =
dir=3D"auto"><br></div><div dir=3D"auto"><br></div><div dir=3D"auto"><div c=
lass=3D"gmail_extra"><div class=3D"gmail_quote"><blockquote class=3D"quote"=
style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><d=
iv dir=3D"ltr"><div><br>That's why I think using named parameters via d=
esignated initilizers is really the way to go to get this behavior.<br></di=
v></div><div class=3D"quoted-text">
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a08da561-78d7-4dfe-8b22-d03b9b933ebe%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/a08d=
a561-78d7-4dfe-<wbr>8b22-d03b9b933ebe%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAFdMc-1qSOjSpsDkG0n64k%2B%3Dngj85cFP=
pqaYg5%3DKZmK1Yx5BQQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFdMc-1qSO=
jSpsDkG0n64k%2B%3Dngj85cFPpqaYg5%3DKZmK1Yx5BQQ%40mail.gmail.com</a>.<br />
--001a1147e8c42d3949054cef2d8b--
.