220 19935 <CADvuK0KRed837_cjEpPSznMvqJCV_LZ5dFpbZ4barstddJKCmg@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: "Arthur O'Dwyer" <arthur.j.odwyer@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: default arguments
Date: Wed, 19 Aug 2015 16:53:11 -0700
Lines: 400
Approved: news@gmane.org
Message-ID: <CADvuK0KRed837_cjEpPSznMvqJCV_LZ5dFpbZ4barstddJKCmg@mail.gmail.com>
References: <ef9c7cbe-e8f1-4196-83bc-11a1c9b2798c@isocpp.org>
	<CANh8DEnn-PWZRNUvqhjcaJpiZk+6hyxVpy5qQXgTUw-uMhdh1A@mail.gmail.com>
	<ccf43684-c479-420e-a6b2-5a23673f7c5a@isocpp.org>
	<89bf9d09-00ed-45db-bf88-39c844707bd1@isocpp.org>
	<b003ffb3-2f0b-4c41-8db0-0a57743e5d93@isocpp.org>
	<CAD6_Qj9xzNThT7wX+LN-Rqe7CNys7s4jr==gzRoirOxCWefGwQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=e89a8f647a39c5acd3051db2bc9d
X-Trace: ger.gmane.org 1440028414 5482 80.91.229.3 (19 Aug 2015 23:53:34 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 19 Aug 2015 23:53:34 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDLZJYWNDQIORLOUVYCRUBHD2CGHC@isocpp.org Thu Aug 20 01:53:23 2015
Return-path: <std-proposals+bncBDLZJYWNDQIORLOUVYCRUBHD2CGHC@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pa0-f71.google.com ([209.85.220.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDLZJYWNDQIORLOUVYCRUBHD2CGHC@isocpp.org>)
	id 1ZSDAQ-0008Fl-H0
	for gclcip-std-proposals@m.gmane.org; Thu, 20 Aug 2015 01:53:14 +0200
Original-Received: by paom9 with SMTP id m9sf37651428pao.3
        for <gclcip-std-proposals@m.gmane.org>; Wed, 19 Aug 2015 16:53:13 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to:content-type:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=NO3ZbQvHKApE/NIW9z/b033qbgYNkI0CmGebYiguTnE=;
        b=QI1mqLZa8PiL0BUNVYd3jRcz8RZ8geBUsSyKnNJxtjXkw+TnzbsOULvCrFmYXd7yNA
         8acFGjUUSiblMZUGyjpiIGa9eABxY9+vpREJwXecAGBDWL6/zVZkGlBc9VK8OxBdHPP8
         5ydYnWO8PxVyMPXXnIQBYufdsgqmtuOKSvKzoMigjA+QKrppvg3uNfrI2WhH3dKDnyYL
         /Ruexib1d1QrY/0X7XqWjoVnXH21PMHmcg9wrf1YOyDrlOZsE++0aXVnGC4NQ6qbk33Z
         uWK5pIDH9PPpCNWfnWbW2Da+GRAkg+79ruBnaI6Qhnxuso53qr0gf/2Ca2FkdXh/pr3j
         v1kw==
X-Gm-Message-State: ALoCoQl3f0G67QfgfshMI7pu8xqMovepgOoV+53Qs3f+50w6TMfYcrhqDaG7BsaVe9Ne140scQrA
X-Received: by 10.68.65.103 with SMTP id w7mr129685pbs.3.1440028393267;
        Wed, 19 Aug 2015 16:53:13 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.78.106 with SMTP id a10ls154406obx.43.gmail; Wed, 19 Aug
 2015 16:53:12 -0700 (PDT)
X-Received: by 10.60.178.212 with SMTP id da20mr163344oec.70.1440028392334;
        Wed, 19 Aug 2015 16:53:12 -0700 (PDT)
Original-Received: from mail-ob0-x22d.google.com (mail-ob0-x22d.google.com. [2607:f8b0:4003:c01::22d])
        by mx.google.com with ESMTPS id 194si1723639oif.69.2015.08.19.16.53.12
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 19 Aug 2015 16:53:12 -0700 (PDT)
Received-SPF: pass (google.com: domain of arthur.j.odwyer@gmail.com designates 2607:f8b0:4003:c01::22d as permitted sender) client-ip=2607:f8b0:4003:c01::22d;
Original-Received: by obbwr7 with SMTP id wr7so18605326obb.2
        for <std-proposals@isocpp.org>; Wed, 19 Aug 2015 16:53:12 -0700 (PDT)
X-Received: by 10.182.107.233 with SMTP id hf9mr18073obb.35.1440028392006;
 Wed, 19 Aug 2015 16:53:12 -0700 (PDT)
Original-Received: by 10.60.35.137 with HTTP; Wed, 19 Aug 2015 16:53:11 -0700 (PDT)
In-Reply-To: <CAD6_Qj9xzNThT7wX+LN-Rqe7CNys7s4jr==gzRoirOxCWefGwQ@mail.gmail.com>
X-Original-Sender: arthur.j.odwyer@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of arthur.j.odwyer@gmail.com designates 2607:f8b0:4003:c01::22d as
 permitted sender) smtp.mailfrom=arthur.j.odwyer@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (p=NONE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:19935
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19935>

--e89a8f647a39c5acd3051db2bc9d
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On the subject of C and named parameters, I'll add that Ben Klemens' "21st
Century C" <http://shop.oreilly.com/product/0636920025108.do> shows a very
nice idiom for getting Python-style named parameters out of a C99 compiler.
I'm paraphrasing from memory a bit in the code sample below...

struct MyFunc_parameters {
  int buffer_size;
  int timeout;
  int tries;
};
#define MyFunc(...) MyFunc_((struct MyFunc_parameters){ .buffer_size=3D1024=
,
..timeout=3D5, .tries=3D3, ##__VA_ARGS__ })
void MyFunc_(struct MyFunc_parameters p) {
  for (int i=3D0; i < p.tries; ++i) {
    allocate(p.buffer_size);
    if (time() > p.timeout) bail();
  }
}

int main() {
  MyFunc();
  MyFunc(.buffer_size =3D 2048);
  MyFunc(.timeout =3D 10);
  MyFunc(.tries =3D 5, .buffer_size =3D 2048);
}

(I don't think the book is suggesting that every function in every C
program ought to use this idiom, any more than every Python function ought
to use **kwargs. It's just a nice technique for building user-friendly C99
APIs.)

This uses a whole bunch of C99-specific features; it's unlikely that C++
will *ever* get *all* of the necessary features. But it shows that you
don't need specific language-level support for defaulted parameters in
order to achieve Pythonesque syntax =E2=80=94 and in fact a syntax *nicer* =
than
C++98's defaulted parameters! (Because the caller doesn't need to care
about the order in which the callee declared its arguments; and because
it's obvious to the callee that the "parameters"' names are part of the
API.)

=E2=80=93Arthur



On Wed, Aug 19, 2015 at 10:50 AM, David Rodr=C3=ADguez Ibeas <dibeas@ieee.o=
rg>
wrote:

> How does that violate an encapsulation that does not exist? All members
> are public in the struct=E2=80=A6 you might dislike it on different accou=
nts but
> encapsulation is not an issue with that code.  Other pro=C2=B4s, the argu=
ments
> are named, which is stable across refactors that might shift the position=
s
> (assuming sensible names, the caller wants the 'a' to have value X or the
> 'b' to have value Z. Depending on the position of the member in the struc=
t
> (and passing 'default' if needed for the previous arguments) is *more*
> coupled, not less coupled.
>
> For initialization of structs, the C way is clearly better than the C++
> way here. A different question is whether we want to put some effort into
> that part of the language when we can assume that most types are not
> all-members-public.
>
> Then again this is only related to default arguments to functions in that
> uniform initialization would be even less uniform in certain cases.  I do
> see the problems with named arguments, I still think that to be the bette=
r
> way. Whether initialization of structs can be made compatible with C once
> again=E2=80=A6 would be nice here, but I imagine not that many people car=
e.
>
>      David
>
> On Wed, Aug 19, 2015 at 5:27 PM, Arthur Tchaikovsky <atch.cpp@gmail.com>
> wrote:
>
>> It *is not* simpler. What you've just shown is a violation of
>> encapsulation. Not simplification.
>>
>>
>> On Wednesday, 19 August 2015 16:08:52 UTC+1, S.B. wrote:
>>>
>>> It's even simpler if we could write
>>>
>>> struct s {
>>>     int a =3D 1337;
>>>     int b =3D 4096;
>>> };
>>>
>>> int main() {
>>>     s x;
>>>     s y { 42 }; // or s y { .a =3D 42 };
>>>     s z { .b =3D 42 };
>>>     return 0;
>>> }
>>>
>>> :)
>>>
>>> On Wednesday, August 19, 2015 at 2:02:01 PM UTC+8, Max Truxa wrote:
>>>>
>>>> I have to agree with Matt Calabrese completely. As it was already
>>>> asserted named arguments are not going to happen anytime soon (if at a=
ll).
>>>>
>>>> Earlier in this thread there were workarounds listed which are more or
>>>> less comparable to the proposal in their effect.
>>>> I would like to elaborate some more on one of these workarounds, as it
>>>> can be mapped pretty much 1-to-1 to the proposal and it happens to be =
the
>>>> solution I employ when encountering this kind of problem.
>>>>
>>>>
>>>> # Current workaround.
>>>>
>>>> struct s {
>>>>     static int const default_a =3D 1337;
>>>>     static int const default_b =3D 4096;
>>>>     s(int a =3D default_a, int b =3D default_b)
>>>>         : a(a), b(b) { }
>>>>     int a;
>>>>     int b;
>>>> };
>>>>
>>>> int main() {
>>>>     s x;
>>>>     s y(42);
>>>>     s z(s::default_a, 42);
>>>>     return 0;
>>>> }
>>>>
>>>> See working code here: http://ideone.com/OKtbuc
>>>>
>>>>
>>>> # Using the proposed syntax.
>>>>
>>>> struct s {
>>>>     s(int a =3D 1337, int b =3D 4096)
>>>>         : a(a), b(b) { }
>>>>     int a;
>>>>     int b;
>>>> };
>>>>
>>>> int main() {
>>>>     s x;
>>>>     s y(42);
>>>>     s z(default, 42);
>>>>     return 0;
>>>> }
>>>>
>>>> The current solution has a number of drawbacks.
>>>> 1) It's unnecessarily verbose.
>>>> 2) It's easy to mess up for parameters that have the same type. (`s
>>>> z(s::default_b, 42)` - Oops, passed `default_b` as `a`.)
>>>> 3) When looking up the actual default values there is one more hop to
>>>> make. It's not sufficient to look at the function declaration but
>>>> additionally we have to look for e.g. default_a.
>>>>
>>>> --
>>
>> ---
>> 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.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/3iegpTsMuT0/=
unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>

--=20

---=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--e89a8f647a39c5acd3051db2bc9d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On the subject of C and named parameters, I&#39;ll add tha=
t <a href=3D"http://shop.oreilly.com/product/0636920025108.do">Ben Klemens&=
#39; &quot;21st Century C&quot;</a> shows a very nice idiom for getting Pyt=
hon-style named parameters out of a C99 compiler. I&#39;m paraphrasing from=
 memory a bit in the code sample below...<br><br><div><font face=3D"monospa=
ce, monospace">struct MyFunc_parameters {</font></div><div><font face=3D"mo=
nospace, monospace">=C2=A0 int buffer_size;</font></div><div><font face=3D"=
monospace, monospace">=C2=A0 int timeout;</font></div><div><font face=3D"mo=
nospace, monospace">=C2=A0 int tries;</font></div><div><font face=3D"monosp=
ace, monospace">};<br></font></div><div><font face=3D"monospace, monospace"=
>#define MyFunc(...) MyFunc_((struct MyFunc_parameters){ .buffer_size=3D102=
4, .timeout=3D5, .tries=3D3, ##__VA_ARGS__ })</font></div><div><font face=
=3D"monospace, monospace">void MyFunc_(struct MyFunc_parameters p) {</font>=
</div><div><font face=3D"monospace, monospace">=C2=A0 for (int i=3D0; i &lt=
; p.tries; ++i) {</font></div><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0 allocate(p.buffer_size);</font></div><div><font face=3D"monospac=
e, monospace">=C2=A0 =C2=A0 if (time() &gt; p.timeout) bail();</font></div>=
<div><font face=3D"monospace, monospace">=C2=A0 }</font></div><div><font fa=
ce=3D"monospace, monospace">}<br></font></div><div><font face=3D"monospace,=
 monospace"><br></font></div><div><font face=3D"monospace, monospace">int m=
ain() {</font></div><div><font face=3D"monospace, monospace">=C2=A0 MyFunc(=
);</font></div><div><font face=3D"monospace, monospace">=C2=A0 MyFunc(.buff=
er_size =3D 2048);</font></div><div><font face=3D"monospace, monospace">=C2=
=A0 MyFunc(.timeout =3D 10);</font></div><div><font face=3D"monospace, mono=
space">=C2=A0 MyFunc(.tries =3D 5, .buffer_size =3D 2048);</font></div><div=
><font face=3D"monospace, monospace">}</font></div><div><br></div><div>(I d=
on&#39;t think the book is suggesting that every function in every C progra=
m ought to use this idiom, any more than every Python function ought to use=
 <font face=3D"monospace, monospace">**kwargs</font>. It&#39;s just a nice =
technique for building user-friendly C99 APIs.)</div><div><br></div><div>Th=
is uses a whole bunch of C99-specific features; it&#39;s unlikely that C++ =
will <i>ever</i> get <i>all</i> of the necessary features. But it shows tha=
t you don&#39;t need specific language-level support for defaulted paramete=
rs in order to achieve Pythonesque syntax =E2=80=94 and in fact a syntax <i=
>nicer</i> than C++98&#39;s defaulted parameters! (Because the caller doesn=
&#39;t need to care about the order in which the callee declared its argume=
nts; and because it&#39;s obvious to the callee that the &quot;parameters&q=
uot;&#39; names are part of the API.)</div><div><br></div><div>=E2=80=93Art=
hur</div><div><br></div><div><br></div></div><div class=3D"gmail_extra"><br=
><div class=3D"gmail_quote">On Wed, Aug 19, 2015 at 10:50 AM, David Rodr=C3=
=ADguez Ibeas <span dir=3D"ltr">&lt;<a href=3D"mailto:dibeas@ieee.org" targ=
et=3D"_blank">dibeas@ieee.org</a>&gt;</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">How does that violate an encapsulation that doe=
s not exist? All members are public in the struct=E2=80=A6 you might dislik=
e it on different accounts but encapsulation is not an issue with that code=
..=C2=A0 Other pro=C2=B4s, the arguments are named, which is stable across r=
efactors that might shift the positions (assuming sensible names, the calle=
r wants the &#39;a&#39; to have value X or the &#39;b&#39; to have value Z.=
 Depending on the position of the member in the struct (and passing &#39;de=
fault&#39; if needed for the previous arguments) is *more* coupled, not les=
s coupled.<div><br></div><div>For initialization of structs, the C way is c=
learly better than the C++ way here. A different question is whether we wan=
t to put some effort into that part of the language when we can assume that=
 most types are not all-members-public.=C2=A0</div><div><br></div><div>Then=
 again this is only related to default arguments to functions in that unifo=
rm initialization would be even less uniform in certain cases.=C2=A0 I do s=
ee the problems with named arguments, I still think that to be the better w=
ay. Whether initialization of structs can be made compatible with C once ag=
ain=E2=80=A6 would be nice here, but I imagine not that many people care.</=
div><div><br></div><div>=C2=A0 =C2=A0 =C2=A0David</div></div><div class=3D"=
gmail_extra"><br><div class=3D"gmail_quote">On Wed, Aug 19, 2015 at 5:27 PM=
, Arthur Tchaikovsky <span dir=3D"ltr">&lt;<a href=3D"mailto:atch.cpp@gmail=
..com" target=3D"_blank">atch.cpp@gmail.com</a>&gt;</span> wrote:<br><blockq=
uote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc =
solid;padding-left:1ex"><div dir=3D"ltr">It *is not* simpler. What you&#39;=
ve just shown is a violation of encapsulation. Not simplification.<div><div=
><br><br>On Wednesday, 19 August 2015 16:08:52 UTC+1, S.B.  wrote:<blockquo=
te class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">It&#39;s even simpler if we=
 could write <br><br><div style=3D"background-color:rgb(250,250,250);border=
-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break=
-word"><code><div><span style=3D"color:#008">struct</span><span style=3D"co=
lor:#000"> s </span><span style=3D"color:#660">{</span><span style=3D"color=
:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">int</span><span =
style=3D"color:#000"> a </span><span style=3D"color:#660">=3D</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#066">1337</span><span sty=
le=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color:#008">int</span><span style=3D"color:#000"> b </spa=
n><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><=
span style=3D"color:#066">4096</span><span style=3D"color:#660">;</span><sp=
an style=3D"color:#000"><br></span><span style=3D"color:#660">};</span><spa=
n style=3D"color:#000"><br>=C2=A0<br></span><span style=3D"color:#008">int<=
/span><span style=3D"color:#000"> main</span><span style=3D"color:#660">()<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660">{</span=
><span style=3D"color:#000"><br>=C2=A0 =C2=A0 s x</span><span style=3D"colo=
r:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 s y </span><sp=
an style=3D"color:#660">{</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#066">42</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">};</span><span style=3D"color:#000"> </span><span style=3D"=
color:#800">// or s y { .a =3D 42 };</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 s z </span><span style=3D"color:#660">{</span><span style=3D"=
color:#000"> </span><span style=3D"color:#660">.</span><span style=3D"color=
:#000">b </span><span style=3D"color:#660">=3D</span><span style=3D"color:#=
000"> </span><span style=3D"color:#066">42</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br=
>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span style=
=3D"color:#000"> </span><span style=3D"color:#066">0</span><span style=3D"c=
olor:#660">;</span><span style=3D"color:#000"><br></span><span style=3D"col=
or:#660">}</span></div></code></div><br>:)<br><br>On Wednesday, August 19, =
2015 at 2:02:01 PM UTC+8, Max Truxa wrote:<blockquote class=3D"gmail_quote"=
 style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-lef=
t:1ex">I have to agree with Matt Calabrese completely. As it was already as=
serted named arguments are not going to happen anytime soon (if at all).<p>=
Earlier in this thread there were workarounds listed which are more or less=
 comparable to the proposal in their effect.<br>I would like to elaborate s=
ome more on one of these workarounds, as it can be mapped pretty much 1-to-=
1 to the proposal and it happens to be the solution I employ when encounter=
ing this kind of problem.</p><p><br># Current workaround.</p><p>struct s {<=
br>=C2=A0 =C2=A0 static int const default_a =3D 1337;<br>=C2=A0 =C2=A0 stat=
ic int const default_b =3D 4096;<br>=C2=A0 =C2=A0 s(int a =3D default_a, in=
t b =3D default_b) <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 : a(a), b(b) { }<br>=C2=
=A0 =C2=A0 int a;<br>=C2=A0 =C2=A0 int b;<br>};<br>=C2=A0<br>int main() {<b=
r>=C2=A0 =C2=A0 s x;<br>=C2=A0 =C2=A0 s y(42);<br>=C2=A0 =C2=A0 s z(s::defa=
ult_a, 42);<br>=C2=A0 =C2=A0 return 0;<br>}</p><p>See working code here: <a=
 href=3D"http://ideone.com/OKtbuc" rel=3D"nofollow" target=3D"_blank">http:=
//ideone.com/OKtbuc</a></p><p><br># Using the proposed syntax.</p><p>struct=
 s {<br>=C2=A0 =C2=A0 s(int a =3D 1337, int b =3D 4096) <br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 : a(a), b(b) { }<br>=C2=A0 =C2=A0 int a;<br>=C2=A0 =C2=A0 int=
 b;<br>};<br>=C2=A0<br>int main() {<br>=C2=A0 =C2=A0 s x;<br>=C2=A0 =C2=A0 =
s y(42);<br>=C2=A0 =C2=A0 s z(default, 42);<br>=C2=A0 =C2=A0 return 0;<br>}=
</p><p>The current solution has a number of drawbacks.<br>1) It&#39;s unnec=
essarily verbose.<br>2) It&#39;s easy to mess up for parameters that have t=
he same type. (`s z(s::default_b, 42)` - Oops, passed `default_b` as `a`.)<=
br>3) When looking up the actual default values there is one more hop to ma=
ke. It&#39;s not sufficient to look at the function declaration but additio=
nally we have to look for e.g. default_a.</p><span class=3D"HOEnZb"><font c=
olor=3D"#888888"><p></p><p></p><p></p><p></p><p></p><p></p></font></span></=
blockquote></div></blockquote></div></div></div><span class=3D"HOEnZb"><fon=
t color=3D"#888888"><div><div>

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; 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@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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></font></span></blockquote></div><span class=3D"HOEnZb"><font c=
olor=3D"#888888"><br></font></span></div><span class=3D"HOEnZb"><font color=
=3D"#888888">

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/3iegpTsMuT0/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/3iegpTsMuT0=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_blank">std-prop=
osals+unsubscribe@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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; 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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--e89a8f647a39c5acd3051db2bc9d--

.
