220 19926 <89bf9d09-00ed-45db-bf88-39c844707bd1@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: "S.B." <i.and.my.little.friends@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: default arguments
Date: Wed, 19 Aug 2015 08:08:52 -0700 (PDT)
Lines: 200
Approved: news@gmane.org
Message-ID: <89bf9d09-00ed-45db-bf88-39c844707bd1@isocpp.org>
References: <ef9c7cbe-e8f1-4196-83bc-11a1c9b2798c@isocpp.org>
 <CANh8DEnn-PWZRNUvqhjcaJpiZk+6hyxVpy5qQXgTUw-uMhdh1A@mail.gmail.com>
 <ccf43684-c479-420e-a6b2-5a23673f7c5a@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_5858_1598653176.1439996932421"
X-Trace: ger.gmane.org 1439996951 21738 80.91.229.3 (19 Aug 2015 15:09:11 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 19 Aug 2015 15:09:11 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDLPV3M6UAHBBBNY2KXAKGQELCDDAQA@isocpp.org Wed Aug 19 17:09:09 2015
Return-path: <std-proposals+bncBDLPV3M6UAHBBBNY2KXAKGQELCDDAQA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-io0-f197.google.com ([209.85.223.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDLPV3M6UAHBBBNY2KXAKGQELCDDAQA@isocpp.org>)
	id 1ZS4z2-0006Xe-7u
	for gclcip-std-proposals@m.gmane.org; Wed, 19 Aug 2015 17:08:56 +0200
Original-Received: by iodt126 with SMTP id t126sf17028419iod.0
        for <gclcip-std-proposals@m.gmane.org>; Wed, 19 Aug 2015 08:08:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :content-type:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=oII9HcnRKX2WKXRzAVZdHfTZchqwpI8S06bvD2psI5Q=;
        b=Pdo9m3i/tuEkdaDWwOk2AIOTsZZGSYqmmqHy96TGsEJQhCgmav4FRB9FAJLLH+4f6Y
         b+ABhqkoi1fA2KEOBy1q3xIXXiRgr7b3tXX5sFeK39eo7YfzepjRF1Vy8O3UmM14hFle
         avsOu91UVH+VQTBmquLsDGNYwFcKv6eHSQakXbfIyzQS5p8z0Uc6gYPfhhcJdfA0KhIh
         2128GldyYoO5+SefWfhD9LWIbgQIu1OsLZJAYYnvcjD2DPuvrg2BhTbOX7T5O5kSDkpt
         DTj3AjhvtnJ5J/7d6SlEq3UI8pYFNvpe1LbM20USNyYnVvIYaxDSAX757e7QRGF7XZcG
         QE7Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:content-type:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=oII9HcnRKX2WKXRzAVZdHfTZchqwpI8S06bvD2psI5Q=;
        b=HBCx+uEEyUOyrewyepmOHgvLwWIPJrSXohxYqu8InMKFEi4NvcqNYRDd11B2n8LxIV
         uGjpn3Z0LWzW1VCBi1wpdiZnrEMcypx/oGNyYRjqVfx+/c8/SE4q/pD5lRUetH2U34D2
         U/77sUuRWiVHxE6o1g5lSnR7AuxX6JMf0PyCBVFBOarvR5QJM/qxKUKWv7NNmbI3EsKE
         EtEmoVl6QOh0x5fDCZM9nu4/FC0GDqrbkhJAwhujz+xVaa4JjlzJhuKhjo8SYz4/5XMO
         6jODi4guOhmpkAmlPXtcftklaJKuyRMAa4IZdGCd3XJEFjulr7HYNjIELK5XAPpnOWKy
         z87w==
X-Gm-Message-State: ALoCoQnYqtRLtO5o5B/ktxliRUILmyvTuj3Dy3uyuROwZSVLjNn0u+BZ3l4wUH1yHy94aGwgBacV
X-Received: by 10.107.170.212 with SMTP id g81mr10579558ioj.19.1439996934604;
        Wed, 19 Aug 2015 08:08:54 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.44.66 with SMTP id f60ls156963qga.6.gmail; Wed, 19 Aug
 2015 08:08:53 -0700 (PDT)
X-Received: by 10.140.19.208 with SMTP id 74mr176108qgh.0.1439996933204;
        Wed, 19 Aug 2015 08:08:53 -0700 (PDT)
In-Reply-To: <ccf43684-c479-420e-a6b2-5a23673f7c5a@isocpp.org>
X-Original-Sender: I.and.my.little.friends@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:19926
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19926>

------=_Part_5858_1598653176.1439996932421
Content-Type: multipart/alternative; 
	boundary="----=_Part_5859_389752403.1439996932421"

------=_Part_5859_389752403.1439996932421
Content-Type: text/plain; charset=UTF-8

It's even simpler if we could write 

struct s {
    int a = 1337;
    int b = 4096;
};
 
int main() {
    s x;
    s y { 42 }; // or s y { .a = 42 };
    s z { .b = 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 all).
>
> 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 = 1337;
>     static int const default_b = 4096;
>     s(int a = default_a, int b = 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 = 1337, int b = 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 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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_5859_389752403.1439996932421
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">It&#39;s even simpler if we could write <br><br><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-colo=
r: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: b=
reak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> s </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>=C2=A0 =C2=A0 </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> a </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">1337</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">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 sty=
le=3D"color: #066;" class=3D"styled-by-prettify">4096</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>=C2=A0<br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> main</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 s x</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 =
=C2=A0 s y </span><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: #066;" class=3D"styled-by-prettify">42</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// or s y { .a =3D 42 };</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 s z </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">b </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">=
42</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span></div></code></div><br>:)<br><br>On Wednesd=
ay, 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 #cc=
c solid;padding-left: 1ex;">I have to agree with Matt Calabrese completely.=
 As it was already asserted named arguments are not going to happen anytime=
 soon (if at all).<p>Earlier in this thread there were workarounds listed w=
hich are more or less comparable to the proposal in their effect.<br>I woul=
d like to elaborate some more on one of these workarounds, as it can be map=
ped pretty much 1-to-1 to the proposal and it happens to be the solution I =
employ when encountering this kind of problem.</p><p><br># Current workarou=
nd.</p><p>struct s {<br>=C2=A0 =C2=A0 static int const default_a =3D 1337;<=
br>=C2=A0 =C2=A0 static int const default_b =3D 4096;<br>=C2=A0 =C2=A0 s(in=
t a =3D default_a, int 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() {<br>=C2=A0 =C2=A0 s x;<br>=C2=A0 =C2=A0 s y(42);<br>=C2=
=A0 =C2=A0 s z(s::default_a, 42);<br>=C2=A0 =C2=A0 return 0;<br>}</p><p>See=
 working code here: <a href=3D"http://ideone.com/OKtbuc" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.com/url?=
q\75http%3A%2F%2Fideone.com%2FOKtbuc\46sa\75D\46sntz\0751\46usg\75AFQjCNFJT=
tR-2NKU_hCXpY0qHPmkHWZV9g&#39;;return true;" onclick=3D"this.href=3D&#39;ht=
tp://www.google.com/url?q\75http%3A%2F%2Fideone.com%2FOKtbuc\46sa\75D\46snt=
z\0751\46usg\75AFQjCNFJTtR-2NKU_hCXpY0qHPmkHWZV9g&#39;;return true;">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><p></p><p></p><p></p><p></p><p=
></p><p></p></blockquote></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 />

------=_Part_5859_389752403.1439996932421--
------=_Part_5858_1598653176.1439996932421--

.
