220 22792 <CAB+4KH+Z9K1b55Je9ObAUhY_EJY6zjGvFjpMcnRCdOmHykEb2w@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Andrew Tomazos <andrewtomazos@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Designated initializer list status?
Date: Sat, 21 Nov 2015 16:22:34 +0100
Lines: 195
Approved: news@gmane.org
Message-ID: <CAB+4KH+Z9K1b55Je9ObAUhY_EJY6zjGvFjpMcnRCdOmHykEb2w@mail.gmail.com>
References: <8b5cda67-8c22-41b6-b99d-ac2ab22f30d2@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a1148e93ebbb6d705250e8fdb
X-Trace: ger.gmane.org 1448119358 8973 80.91.229.3 (21 Nov 2015 15:22:38 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 21 Nov 2015 15:22:38 +0000 (UTC)
To: "std-proposals@isocpp.org" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBD5KHQXXWYPRBO4YYKZAKGQEPE4CKLY@isocpp.org Sat Nov 21 16:22:37 2015
Return-path: <std-proposals+bncBD5KHQXXWYPRBO4YYKZAKGQEPE4CKLY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lb0-f200.google.com ([209.85.217.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD5KHQXXWYPRBO4YYKZAKGQEPE4CKLY@isocpp.org>)
	id 1a09zp-0005e7-Aq
	for gclcip-std-proposals@m.gmane.org; Sat, 21 Nov 2015 16:22:37 +0100
Original-Received: by lbces9 with SMTP id es9sf46555817lbc.1
        for <gclcip-std-proposals@m.gmane.org>; Sat, 21 Nov 2015 07:22:36 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=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=RnpO/9E6UCPcdXlmpdh6BfDoFevgv4q/EXjzA2IpXiA=;
        b=YxiuTm3SK7MVNJ2wO33ByhFI/7VFRDew4IFYlMzKRhRBMs4/SgT3F26HQl5VsVPLBY
         TrRwQiH/7HkoSVITDgQVniXFaMZMc912iR3Ro3bOnoS//MiFL0/lXRzobpp0+FgS2kFl
         B1mpCbV543FR/F8sIgg2IDPeL3VYhFk3RTTSCUIRwrWIla/YAvK1XuPXJP4cFR8XL4Fa
         Xqdd8efb2z59ISERvnBAjznknFMmWX0tl7YPruriSGDffP9qSOzy81GrVjXmM9DJDUc7
         ycbUIhTRlf+fD3Gp5BofWxDJi333Rv/W9w7LUIt/KT9THHam855tNuMIRbugNW6cD/Kl
         TNCQ==
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=RnpO/9E6UCPcdXlmpdh6BfDoFevgv4q/EXjzA2IpXiA=;
        b=Mryejd8NZUuvCmJnKY2vGVDsM7cpe22yGd+J2w5kRqclQuoiC8E/FJmJbLRzo+OM+F
         7H9UEwfzCvOkXnd6qFCUU/mnIqf0NL9xiSrVqEM2RoUgL89eYAvzFLFzuKlYGythI5U3
         UbwEpUUlt4HKNK2TfSdyrYWHx/yAe8MIC/TJZeJzT1RFktrPK28kQR9L0PEKEvB8mLS2
         qM5YACKaLneOlAco0WCc++ASYaK6PPfxKOFORD7u39V1xQ9MzX2mSB0gvIsLTv2Ni9CW
         g1H7np0fT8m2myI55SEg3VG+2B/rktVPc9Kmu6dzVVYjIX6kzCRi/YD1F9u7kIFnXIgz
         PIyw==
X-Gm-Message-State: ALoCoQmF0h7IuiORaljgMbFF6d0vqgUR7F6NRI9dtxSIaX6/tTYrpYPQJkF5SZFCIomVkbRnvEBD
X-Received: by 10.112.146.131 with SMTP id tc3mr3808922lbb.18.1448119356563;
        Sat, 21 Nov 2015 07:22:36 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.125.130 with SMTP id y124ls106740wmc.38.gmail; Sat, 21 Nov
 2015 07:22:35 -0800 (PST)
X-Received: by 10.194.121.7 with SMTP id lg7mr3567014wjb.90.1448119355002;
        Sat, 21 Nov 2015 07:22:35 -0800 (PST)
Original-Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com. [2a00:1450:400c:c09::22b])
        by mx.google.com with ESMTPS id f2si6955393wma.46.2015.11.21.07.22.34
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sat, 21 Nov 2015 07:22:34 -0800 (PST)
Received-SPF: pass (google.com: domain of andrewtomazos@gmail.com designates 2a00:1450:400c:c09::22b as permitted sender) client-ip=2a00:1450:400c:c09::22b;
Original-Received: by wmww144 with SMTP id w144so54838160wmw.0
        for <std-proposals@isocpp.org>; Sat, 21 Nov 2015 07:22:34 -0800 (PST)
X-Received: by 10.28.194.84 with SMTP id s81mr8379697wmf.51.1448119354764;
 Sat, 21 Nov 2015 07:22:34 -0800 (PST)
Original-Received: by 10.28.223.69 with HTTP; Sat, 21 Nov 2015 07:22:34 -0800 (PST)
In-Reply-To: <8b5cda67-8c22-41b6-b99d-ac2ab22f30d2@isocpp.org>
X-Original-Sender: andrewtomazos@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of andrewtomazos@gmail.com designates 2a00:1450:400c:c09::22b as
 permitted sender) smtp.mailfrom=andrewtomazos@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:22792
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/22792>

--001a1148e93ebbb6d705250e8fdb
Content-Type: text/plain; charset=UTF-8

https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/IgDFqKjKlRs

On Sat, Nov 21, 2015 at 3:11 PM, <landeholm@gmail.com> wrote:

> Coming from Golang and C I was saddened by the fact that standard C++
> lacks (JSON-esque) designated initializer list support.
>
> Some pragmatic reasons to support it:
> 1. It seem to be some interest in this feature, e.g. 33 votes:
> http://stackoverflow.com/questions/18731707
> 2. It's makes C++ more compatible with C99.
> 3. Many compilers already seem have support for it. I realized it wasn't
> in C++ when I turned on --pedantic.
>
> A contrived example:
>
>     // ...
>
>     class Link {
>     public:
>         int bw;
>         Coord wr_c;
>         Coord bl_c;
>         int src;
>         int mtime;
>         Computer* dst;
>         int u;
>     };
>
>     // ...
>
>     int main() {
>         // ...
>         std::vector<Link> links(m);
>         for (int i = 0; i < m; i++) {
>             int a, b, c;
>             std::cin >> a >> b >> c;
>             links[i] = {c, Coord(), Coord(), a, 0, &comps[b]}; //
> Non-designated
>             links[i] = {.src = a, .dst = &comps[b], .bw = c};  //
> Designated
>         }
>         // ...
>     }
>
> Some (likely highly subjective) problems with the non-designated syntax:
> 1. Order dependent (harder to read).
> 2. Does not scale well, parameter ordering is increasingly difficult to
> track when more fields are added.
> 3. Does not allow explicit initialization of a partial set of fields.
> (harder to read, annoying to write)
>
> 1, 2: Understanding the designated initializer list assignment requires no
> declaration or parameter order knowledge so the grammar is more context
> free and therefore easier to read.
>
> 3: You are forced to write an explicit constructor or enumerate defaults
> for all fields. An explicit constructor would require extra boilerplate and
> introduce another independent order you have to track (more context).
> Writing a constructor for a specific way you want to initialize a class
> seems like code smell.
>
> So I hope this feature would become standardized. Thank you for reading
> my humble opinion.
>
> --
>
> ---
> 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/.
>

-- 

--- 
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/.

--001a1148e93ebbb6d705250e8fdb
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><a href=3D"https://groups.google.com/a/isocpp.org/forum/#!=
topic/std-proposals/IgDFqKjKlRs">https://groups.google.com/a/isocpp.org/for=
um/#!topic/std-proposals/IgDFqKjKlRs</a><br></div><div class=3D"gmail_extra=
"><br><div class=3D"gmail_quote">On Sat, Nov 21, 2015 at 3:11 PM,  <span di=
r=3D"ltr">&lt;<a href=3D"mailto:landeholm@gmail.com" target=3D"_blank">land=
eholm@gmail.com</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"><di=
v dir=3D"ltr"><div>Coming from Golang and C I was saddened by the fact that=
 standard C++ lacks (JSON-esque) designated initializer list support.<br></=
div><div><br></div><div>Some pragmatic reasons to support it:</div><div>1. =
It seem to be some interest in this feature, e.g. 33 votes:=C2=A0<a href=3D=
"http://stackoverflow.com/questions/18731707" target=3D"_blank">http://stac=
koverflow.com/questions/18731707</a></div><div>2. It&#39;s makes C++ more c=
ompatible with C99.</div><div>3. Many compilers already seem have support f=
or it. I realized it wasn&#39;t in C++ when I turned on --pedantic.</div><d=
iv><br></div><div>A contrived example:</div><div><br></div><div><div><font =
face=3D"courier new, monospace">=C2=A0 =C2=A0 // ...</font></div><div><font=
 face=3D"courier new, monospace"><br></font></div><div><font face=3D"courie=
r new, monospace">=C2=A0 =C2=A0 class Link {</font></div><div><font face=3D=
"courier new, monospace">=C2=A0 =C2=A0 public:</font></div><div><font face=
=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 int bw;</font></div=
><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 Coo=
rd wr_c;</font></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 Coord bl_c;</font></div><div><font face=3D"courier new, m=
onospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 int src;</font></div><div><font face=
=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 int mtime;</font></=
div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
Computer* dst;</font></div><div><font face=3D"courier new, monospace">=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 int u;</font></div><div><font face=3D"courier new,=
 monospace">=C2=A0 =C2=A0 };</font></div><div><font face=3D"courier new, mo=
nospace"><br></font></div><div><font face=3D"courier new, monospace">=C2=A0=
 =C2=A0 // ...</font></div><div><font face=3D"courier new, monospace"><br><=
/font></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 int ma=
in() {</font></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0=
 =C2=A0 =C2=A0 // ...</font></div><div><font face=3D"courier new, monospace=
">=C2=A0 =C2=A0 =C2=A0 =C2=A0 std::vector&lt;Link&gt; links(m);</font></div=
><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 for=
 (int i =3D 0; i &lt; m; i++) {</font></div><div><font face=3D"courier new,=
 monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 int a, b, c;</font></=
div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 std::cin &gt;&gt; a &gt;&gt; b &gt;&gt; c;</font></div><div><=
font face=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 links[i] =3D {c, Coord(), Coord(), a, 0, &amp;comps[b]}; // Non-designa=
ted</font></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 links[i] =3D {.src =3D a, .dst =3D &amp;comps[b=
], .bw =3D c}; =C2=A0// Designated</font></div><div><font face=3D"courier n=
ew, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 }</font></div><div><font face=3D=
"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 // ...</font></div><di=
v><font face=3D"courier new, monospace">=C2=A0 =C2=A0 }</font></div></div><=
div><br></div><div>Some (likely highly subjective) problems with the non-de=
signated syntax:<br></div><div>1. Order dependent (harder to read).</div><d=
iv>2. Does not scale well, parameter ordering is increasingly difficult to =
track when more fields are added.</div><span style=3D"font-family:arial,san=
s-serif">3. Does not allow explicit initialization of a partial set of fiel=
ds. (harder to read, annoying to write)</span><div><br></div><div>1, 2: Und=
erstanding the designated initializer list assignment requires no declarati=
on or parameter order knowledge so the grammar is more context free and the=
refore easier to read.<font face=3D"arial, sans-serif"><br></font></div><di=
v><br></div><div>3: You are forced to write an explicit constructor or enum=
erate defaults for all fields. An explicit constructor would require extra =
boilerplate and introduce another independent order you have to track (more=
 context). Writing a constructor for a specific way you want to initialize =
a class seems like code smell.</div><div><br></div><div><font face=3D"arial=
, sans-serif">So=C2=A0</font>I hope this feature would become standardized.=
 Thank you for reading my humble opinion.</div><span class=3D"HOEnZb"><font=
 color=3D"#888888"><div><br></div></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 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>
</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 />

--001a1148e93ebbb6d705250e8fdb--

.
