220 19937 <5F6E90B3-44BE-4A37-BE8F-91E1255E6407@gmail.com> article
Path: news.gmane.org!not-for-mail
From: David Krauss <potswa@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: default arguments
Date: Thu, 20 Aug 2015 09:59:00 +0800
Lines: 157
Approved: news@gmane.org
Message-ID: <5F6E90B3-44BE-4A37-BE8F-91E1255E6407@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> <CADvuK0KRed837_cjEpPSznMvqJCV_LZ5dFpbZ4barstddJKCmg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\))
Content-Type: multipart/alternative; boundary="Apple-Mail=_DB5477E2-B84A-45DE-AD7C-95E5C8FE6C41"
X-Trace: ger.gmane.org 1440035966 13974 80.91.229.3 (20 Aug 2015 01:59:26 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 20 Aug 2015 01:59:26 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCW25A7E3QCRB27I2SXAKGQECFFKB7Q@isocpp.org Thu Aug 20 03:59:13 2015
Return-path: <std-proposals+bncBCW25A7E3QCRB27I2SXAKGQECFFKB7Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-io0-f200.google.com ([209.85.223.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCW25A7E3QCRB27I2SXAKGQECFFKB7Q@isocpp.org>)
	id 1ZSF8H-0002xd-FA
	for gclcip-std-proposals@m.gmane.org; Thu, 20 Aug 2015 03:59:09 +0200
Original-Received: by iofe124 with SMTP id e124sf42072388iof.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 19 Aug 2015 18:59:08 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:content-type:message-id:mime-version
         :subject:date:references:to:in-reply-to: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=0cft4+EdoQUmt8c3rDfxGXQoIc0F6Rhp3f7Qj2jWGUI=;
        b=HM055ZsSntMJE8IHmzydVivUTWFartBPoR7hjPe9+maqGM1D15Tcr3c8fpp7DZs8EO
         JeMeRe/VFEqIg8s2zqsEFq+LS6BHzCZ7e/BKDTNrthxduu2qvbkc8skTzeoq1vi2Uyyk
         3Y+GJUtz7yC6S8Xzo4Lp7de4bgv3WuHMJz5FfalCyyTwzRDCf0iwF8+DdbZ+qYyxct9W
         g6Y2Aqd4J3GdXPr1TTp0Yi+A7Tjlx+0V1w0LwvQ9womL4EU46311YYWsM5zqQ0PHVB9r
         v8w2j258MYp+x4hN/8ershy3W0jU1NN84QHKZHxjyTiuTaUHa0hsX8K80Uezv9OiSfCx
         UkOQ==
X-Gm-Message-State: ALoCoQmplDEjY1qnN1KkSCQTaDim0zwJcXcp5v5664SWJynMHoEykneJUhLvccgm3x+KUTp/omzh
X-Received: by 10.107.28.2 with SMTP id c2mr474270ioc.16.1440035948331;
        Wed, 19 Aug 2015 18:59:08 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.16.163 with SMTP id 35ls291418ioq.71.gmail; Wed, 19 Aug
 2015 18:59:07 -0700 (PDT)
X-Received: by 10.68.125.200 with SMTP id ms8mr1298074pbb.135.1440035947454;
        Wed, 19 Aug 2015 18:59:07 -0700 (PDT)
Original-Received: from mail-pd0-x22e.google.com (mail-pd0-x22e.google.com. [2607:f8b0:400e:c02::22e])
        by mx.google.com with ESMTPS id bc7si4684677pdb.228.2015.08.19.18.59.07
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 19 Aug 2015 18:59:07 -0700 (PDT)
Received-SPF: pass (google.com: domain of potswa@gmail.com designates 2607:f8b0:400e:c02::22e as permitted sender) client-ip=2607:f8b0:400e:c02::22e;
Original-Received: by pdrh1 with SMTP id h1so8136707pdr.0
        for <std-proposals@isocpp.org>; Wed, 19 Aug 2015 18:59:07 -0700 (PDT)
X-Received: by 10.70.96.40 with SMTP id dp8mr1274797pdb.109.1440035946694;
        Wed, 19 Aug 2015 18:59:06 -0700 (PDT)
Original-Received: from [172.20.10.2] ([121.54.54.184])
        by smtp.gmail.com with ESMTPSA id c6sm2301694pat.13.2015.08.19.18.59.04
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Wed, 19 Aug 2015 18:59:05 -0700 (PDT)
In-Reply-To: <CADvuK0KRed837_cjEpPSznMvqJCV_LZ5dFpbZ4barstddJKCmg@mail.gmail.com>
X-Mailer: Apple Mail (2.2098)
X-Original-Sender: potswa@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of potswa@gmail.com designates 2607:f8b0:400e:c02::22e as permitted
 sender) smtp.mailfrom=potswa@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:19937
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19937>

--Apple-Mail=_DB5477E2-B84A-45DE-AD7C-95E5C8FE6C41
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9308=E2=80=9320, at 7:53 AM, Arthur O'Dwyer <arthur.j.odwye=
r@gmail.com> wrote:
>=20
> On the subject of C and named parameters, I'll add that Ben Klemens' "21s=
t Century C" <http://shop.oreilly.com/product/0636920025108.do> shows a ver=
y nice idiom for getting Python-style named parameters out of a C99 compile=
r. I'm paraphrasing from memory a bit in the code sample below=E2=80=A6


Perhaps the syntax of an expression-list beginning with =E2=80=9C.=E2=80=9D=
 should indicate implicit braces, added as sugar. I think that passing a st=
ruct is a superior design when lots of parameters are present, and one supp=
orted by decades of experience.

struct parameters {
  int buffer_size =3D 1024;
  int timeout =3D 10;
  int tries =3D 3;
};

int foo( parameters );
int x =3D foo( .buffer_size =3D 100, .timeout =3D 2, .tries =3D 3 ); // imp=
licit braces

class non_aggregate {
public:
  non_aggregate( int, int, int ); // A
  non_aggregate( parameters ); // B
};

non_aggregate a( 1, 2, 3 ); // A
non_aggregate b{ 1, 2, 3 }; // A
non_aggregate c({ .buffer_size =3D 100, .timeout =3D 2, .tries =3D 3 }); //=
 B (no extension beyond designated initializers)
non_aggregate d{{ .buffer_size =3D 100, .timeout =3D 2, .tries =3D 3 }}; //=
 B (no extension beyond designated initializers)
non_aggregate e( .buffer_size =3D 100, .timeout =3D 2, .tries =3D 3 ); // B=
 (implicit braces)
non_aggregate f{ .buffer_size =3D 100, .timeout =3D 2, .tries =3D 3 }; // e=
rror: braces are implicit only inside parens

It=E2=80=99s better to disallow the last case, because list-initialization =
should represent aggregation; it shouldn=E2=80=99t be used to express gener=
ating an object from a set of abstract parameters or constraints.

--=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/.

--Apple-Mail=_DB5477E2-B84A-45DE-AD7C-95E5C8FE6C41
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9308=
=E2=80=9320, at 7:53 AM, Arthur O'Dwyer &lt;<a href=3D"mailto:arthur.j.odwy=
er@gmail.com" class=3D"">arthur.j.odwyer@gmail.com</a>&gt; wrote:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" style=
=3D"font-family: Helvetica; font-size: 12px; font-style: normal; font-varia=
nt: normal; font-weight: normal; letter-spacing: normal; line-height: norma=
l; orphans: auto; text-align: start; text-indent: 0px; text-transform: none=
; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke=
-width: 0px;" class=3D"">On the subject of C and named parameters, I'll add=
 that<span class=3D"Apple-converted-space">&nbsp;</span><a href=3D"http://s=
hop.oreilly.com/product/0636920025108.do" class=3D"">Ben Klemens' "21st Cen=
tury C"</a><span class=3D"Apple-converted-space">&nbsp;</span>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=E2=80=A6</div>=
</div></blockquote></div><div class=3D""><br class=3D""></div>Perhaps the s=
yntax of an&nbsp;<i class=3D"">expression-list</i>&nbsp;beginning with =E2=
=80=9C<font face=3D"Courier" class=3D"">.</font>=E2=80=9D should indicate i=
mplicit braces, added as sugar.&nbsp;I think that passing a&nbsp;<font face=
=3D"Courier" class=3D"">struct</font>&nbsp;is a superior design when lots o=
f parameters are present, and one supported by decades of experience.<div c=
lass=3D""><div class=3D""><br class=3D""></div><div class=3D""><div class=
=3D""><font face=3D"monospace, monospace" class=3D"">struct parameters {</f=
ont></div><div class=3D""><font face=3D"monospace, monospace" class=3D"">&n=
bsp; int buffer_size =3D 1024;</font></div><div class=3D""><font face=3D"mo=
nospace, monospace" class=3D"">&nbsp; int timeout =3D 10;</font></div><div =
class=3D""><font face=3D"monospace, monospace" class=3D"">&nbsp; int tries =
=3D 3;</font></div><div class=3D""><font face=3D"monospace, monospace" clas=
s=3D"">};<br class=3D""></font></div><div class=3D""><font face=3D"monospac=
e, monospace" class=3D""><br class=3D""></font></div><div class=3D""><font =
face=3D"monospace, monospace" class=3D"">int foo( parameters );</font></div=
><div class=3D""><font face=3D"monospace, monospace" class=3D"">int x =3D f=
oo</font><span style=3D"font-family: monospace, monospace;" class=3D"">( .b=
uffer_size =3D 100, .timeout =3D 2, .tries =3D 3 ); // implicit braces</spa=
n></div><div class=3D""><span style=3D"font-family: monospace, monospace;" =
class=3D""><br class=3D""></span></div><div class=3D""><font face=3D"monosp=
ace, monospace" class=3D"">class non_aggregate {</font></div><div class=3D"=
"><font face=3D"monospace, monospace" class=3D"">public:</font></div><div c=
lass=3D""><font face=3D"monospace, monospace" class=3D"">&nbsp; non_aggrega=
te( int, int, int ); // A</font></div><div class=3D""><font face=3D"monospa=
ce, monospace" class=3D"">&nbsp; non_aggregate(&nbsp;</font><span style=3D"=
font-family: monospace, monospace;" class=3D"">parameters</span><font face=
=3D"monospace, monospace" class=3D"">&nbsp;); // B</font></div><div class=
=3D""><font face=3D"monospace, monospace" class=3D"">};</font></div><div cl=
ass=3D""><font face=3D"monospace, monospace" class=3D""><br class=3D""></fo=
nt></div><div class=3D""><span style=3D"font-family: monospace, monospace;"=
 class=3D"">non_aggregate a( 1, 2, 3 ); // A</span></div><div class=3D""><d=
iv class=3D""><font face=3D"monospace, monospace" class=3D"">non_aggregate =
b{ 1, 2, 3 }; // A</font></div></div><div class=3D""><div class=3D""><font =
face=3D"monospace, monospace" class=3D"">non_aggregate c({ .buffer_size =3D=
 100, .timeout =3D 2, .tries =3D 3 }); // B (no extension</font><span style=
=3D"font-family: monospace, monospace;" class=3D"">&nbsp;</span><span style=
=3D"font-family: monospace, monospace;" class=3D"">beyond designated initia=
lizers</span><span style=3D"font-family: monospace, monospace;" class=3D"">=
)</span></div><div class=3D""><font face=3D"monospace, monospace" class=3D"=
">non_aggregate d{{ .buffer_size =3D 100, .timeout =3D 2, .tries =3D 3 }};<=
/font><font face=3D"monospace, monospace" class=3D"">&nbsp;// B (no extensi=
on</font><span style=3D"font-family: monospace, monospace;" class=3D"">&nbs=
p;</span><span style=3D"font-family: monospace, monospace;" class=3D"">beyo=
nd designated initializers</span><span style=3D"font-family: monospace, mon=
ospace;" class=3D"">)</span></div><div class=3D""><span style=3D"font-famil=
y: monospace, monospace;" class=3D"">non_aggregate e( .buffer_size =3D 100,=
 .timeout =3D 2, .tries =3D 3 ); // B (implicit braces)</span></div><div cl=
ass=3D""><span style=3D"font-family: monospace, monospace;" class=3D"">non_=
aggregate f{ .buffer_size =3D 100, .timeout =3D 2, .tries =3D 3 }; // error=
: braces are implicit only inside parens</span></div></div></div></div><div=
 class=3D""><br class=3D""></div><div class=3D"">It=E2=80=99s better to dis=
allow the last case, because list-initialization should represent aggregati=
on; it shouldn=E2=80=99t be used to express generating an object from a set=
 of abstract parameters or constraints.</div><div class=3D""><br class=3D""=
></div></body></html>

<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 />

--Apple-Mail=_DB5477E2-B84A-45DE-AD7C-95E5C8FE6C41--

.
