220 28275 <0e27bc76-eada-4d70-80d7-b91b5a2d5767@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Something is better then nothing: Please, relax
 Initializer List use with operators!
Date: Sun, 18 Sep 2016 06:08:08 -0700 (PDT)
Lines: 189
Approved: news@gmane.org
Message-ID: <0e27bc76-eada-4d70-80d7-b91b5a2d5767@isocpp.org>
References: <0892f743-bca2-4f18-b023-d4a57cea60fb@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_411_1138377791.1474204088556"
X-Trace: blaine.gmane.org 1474204103 9822 195.159.176.226 (18 Sep 2016 13:08:23 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 18 Sep 2016 13:08:23 +0000 (UTC)
Cc: mihailnajdenov@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBOND7K7AKGQE2OI3RAI@isocpp.org Sun Sep 18 15:08:19 2016
Return-path: <std-proposals+bncBCEKFTV6ZUMBBOND7K7AKGQE2OI3RAI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-io0-f197.google.com ([209.85.223.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBOND7K7AKGQE2OI3RAI@isocpp.org>)
	id 1blbpJ-0000yL-9b
	for gclcip-std-proposals@m.gmane.org; Sun, 18 Sep 2016 15:08:09 +0200
Original-Received: by mail-io0-f197.google.com with SMTP id q92sf204623879ioi.3
        for <gclcip-std-proposals@m.gmane.org>; Sun, 18 Sep 2016 06:08:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version: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=LNUquPVaKhiaH+liLzCL4jd+pMM0hhf+/35zK85YpRE=;
        b=O3USLB8ANT7BOzxkh7lrMiOCs0imZTE+y69jErPoDrl8K5hF1nnCEODZ5yKFfGR8uQ
         etnw5OtXPH8MZwKa4cVX1oLTMhyGZ+yiqfLxSoT+dh3dRzLuJKj0F7bGRz7X93ybVGrI
         GNmcCcSqSHSE8YGBl9kd7AyxCQ/q/fiMG/+Z7BXvE/69UBp7IVaC+1JS/oWm/Qt9gZhs
         sguby4VtmfyT4EdIXpgZ/mz4JZsvVPt83BsckqYEWSYej9n+VoHAyXj0L1VpKZlmIGK7
         HDe7KU6jAnHtJVWbrGGhbXDhP+efmMFGyLsN6GJlagVUWuf4wHLOu6AiZWp171yxHmJe
         ZkOA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version: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=LNUquPVaKhiaH+liLzCL4jd+pMM0hhf+/35zK85YpRE=;
        b=QQuZxgmoftbkezDrzJn87JE6o5S/sTx95d+MmHAnioDp0x6w2brHQ8mAetzEcZGcQ0
         i7o+s+IId84tvSbLyRd+I+4L06lvxSfFxKvyKZc1Arfos8tODULzFfWElfFn+VB02/9l
         5SvGKuxGDM/XFd+OoKs7cMXy17qGDpcbo4WjmZhWN7E+dl8+ZlFtmzTwqxFTBXpWatue
         ZWbGahMM9qEBmyP9Qmn9aLxAKvhNYrLJpH+3qCyxb8AmZqo/9oYVYhLsFHcPiUWFGUIz
         OdgPd4HI4uyAggUq40YCYIyGHO1Qh93PobgWiQ9/t4H5cmFUGN7StqCuJvfEpQOROtOd
         I16Q==
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:cc:message-id:in-reply-to
         :references:subject:mime-version: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=LNUquPVaKhiaH+liLzCL4jd+pMM0hhf+/35zK85YpRE=;
        b=FQLFc2Xq7yhZkCJtb2uzC1ubMcW0oLogwQP19V3SDe7+HVGNCL+5bbg2Pww6qFTmuc
         lSwUV5xQfeTGu93ijSHX00HSbHRI57UVU8tqrLg7PEnkT/MbbgEjwZk5MqRH9fLsq72Z
         jUdoMo1UzqQ21imWwKIOIWtfGUuI7QU53S1t8ojno4zWV3OcRTsuNVt469tJ2VoEtU5W
         bLJzE2BF9W3O9UE6t07rhNI0tLoyzlcAxNCpyyykkjJUxth7/5QHDXgEswfzLWmQfDiL
         sTnEoqCJAGd8T8w45beWxAmxWBP1d5wbGSrddjgsB3sWvUvv+/N1bgojK5ZS7JQ/4oRg
         H8sQ==
X-Gm-Message-State: AE9vXwMsOH0mK3lmzItKcJsT6JXlJk77//nE/bKAohpuoNWhSEVWbmmoeU4S1U7UAhfTMA==
X-Received: by 10.157.56.117 with SMTP id r50mr12802047otd.19.1474204090656;
        Sun, 18 Sep 2016 06:08:10 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.48.1 with SMTP id w1ls2847533iow.4.gmail; Sun, 18 Sep 2016
 06:08:09 -0700 (PDT)
X-Received: by 10.36.103.4 with SMTP id u4mr180404itc.9.1474204089359;
        Sun, 18 Sep 2016 06:08:09 -0700 (PDT)
In-Reply-To: <0892f743-bca2-4f18-b023-d4a57cea60fb@isocpp.org>
X-Original-Sender: jmckesson@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://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>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:28275
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/28275>

------=_Part_411_1138377791.1474204088556
Content-Type: multipart/alternative; 
	boundary="----=_Part_412_1619274301.1474204088557"

------=_Part_412_1619274301.1474204088557
Content-Type: text/plain; charset=UTF-8

On Sunday, September 18, 2016 at 8:41:39 AM UTC-4, mihailn...@gmail.com 
wrote:
>
> Hello, in a recent search about why is Initializer List limited so much 
> (cant be used in arithmetics, assignment, etc), I came to this post : 
> http://stackoverflow.com/a/11445905/362515
>
> Basically the problem is, Initializer List is impossible to work in any 
> situation where operators are used - parsing such an expression will be to 
> complex.
>
> That is fine.
>
> However support in limited, but well defined scenarios is possible and I 
> believe the benefits will still outweigh the confusion why it is not 
> working in some contexts. 
> What is more *there is already a confusion why it is not working in 
> "similar contexts"!* 
>
> For example *from the user perspective assignment and comparison are 
> "similar" contexts of use - one is "are you that thing" the other is 
> "become that thing". *
> Needless to say the syntax is, as we know, dangerously close "==" vs "="
> *.*
>
> If for instance is allowed *only the type of  the RHS in operator to be 
> deduced from an init-list* and expression is dissuaded to start with a 
> init-list, not only many if not all use cases will be possible, *but it 
> will be somewhat easier to teach why the other case is to available.*
>
> Back to the example - it is hard to explain why this is working:
> Point p;
> p = {-1, -1}; 
>
> but this is not:
>
> if(p == {-1, -1}) return;
>
>
Because one is assignment while the other is equality testing. They're two 
different things.

Why is that hard to explain?


> *But this is actually relatively easy to explain why it's not working*:
> if({-1, -1} == p) return;
>
>
Um, no. If we allow `X == Y` to work, then it makes sense that we allow `Y 
== X` to work. To disallow one and not the other is far more bizarre than 
allowing one operation but forbidding a completely different one. 

*Bonus:*
> This must work, it really must work:
> const auto e = car ? car->engine() : {};
>  We know it does not but it should, no reason why not - first arg is 
> given, second arg is given, the the third must the same type as the second, 
> so we have everything to deduce it!
>

Again, that goes back to consistency. `!car ? {} : car->engine()` is 
conceptually the same, yet it wouldn't work under your scheme.

-- 
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/0e27bc76-eada-4d70-80d7-b91b5a2d5767%40isocpp.org.

------=_Part_412_1619274301.1474204088557
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Sunday, September 18, 2016 at 8:41:39 AM UTC-4, mihailn=
....@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">Hello, in a recent search about why is Initializer List limited so=
 much (cant be used in arithmetics, assignment, etc), I came to this post :=
=C2=A0<a href=3D"http://stackoverflow.com/a/11445905/362515" target=3D"_bla=
nk" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;http://www.google.com/=
url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fa%2F11445905%2F362515\x26sa\x3dD\=
x26sntz\x3d1\x26usg\x3dAFQjCNFIspyYdgnbZNGZ4NoXt5FntYe5bg&#39;;return true;=
" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fs=
tackoverflow.com%2Fa%2F11445905%2F362515\x26sa\x3dD\x26sntz\x3d1\x26usg\x3d=
AFQjCNFIspyYdgnbZNGZ4NoXt5FntYe5bg&#39;;return true;">http://stackoverflow.=
com/a/<wbr>11445905/362515</a><div><br></div><div>Basically the problem is,=
 Initializer List is impossible to work in any situation where operators ar=
e used - parsing such an expression will be to complex.</div><div><br></div=
><div>That is fine.</div><div><br></div><div>However support in limited, bu=
t well defined scenarios is possible and I believe the benefits will still =
outweigh the confusion why it is not working in some contexts.=C2=A0</div><=
div>What is more <b>there is already a=C2=A0confusion why it is not working=
 in &quot;similar contexts&quot;!</b>=C2=A0</div><div><b><br></b></div><div=
>For example <b>from the user perspective assignment and comparison are &qu=
ot;similar&quot; contexts of use - one is &quot;are you that thing&quot; th=
e other is &quot;become that thing&quot;.=C2=A0</b></div><div>Needless to s=
ay the syntax is, as we know, dangerously close &quot;=3D=3D&quot; vs &quot=
;=3D&quot;<b>.</b></div><div><b><br></b></div><div>If for instance is allow=
ed <b>only the type of =C2=A0the RHS in operator to be deduced from an init=
-list</b>=C2=A0and expression is dissuaded to start with a init-list, not o=
nly many if not all use cases will be possible, <b>but it will be somewhat =
easier to teach why the other case is to available.</b></div><div><br></div=
><div>Back to the example - it is hard to explain why this is working:</div=
><div><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><d=
iv><span style=3D"color:#606">Point</span><span style=3D"color:#000"> p</sp=
an><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>p </sp=
an><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">{-</span><span style=3D"color:#066">1</span><spa=
n style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">-</span><span style=3D"color:#066">1</span><span style=3D=
"color:#660">};</span><span style=3D"color:#000"> </span></div></code></div=
><div><br></div>but this is not:</div><div><br></div><div><div style=3D"bac=
kground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:s=
olid;border-width:1px;word-wrap:break-word"><code><div><font color=3D"#6600=
66"><span style=3D"color:#008">if</span><span style=3D"color:#660">(</span>=
<span style=3D"color:#000">p </span><span style=3D"color:#660">=3D=3D</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">{-</span><sp=
an style=3D"color:#066">1</span><span style=3D"color:#660">,</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#660">-</span><span style=
=3D"color:#066">1</span><span style=3D"color:#660">})</span><span style=3D"=
color:#000"> </span><span style=3D"color:#008">return</span><span style=3D"=
color:#660">;</span></font></div></code></div><div><br></div></div></div></=
blockquote><div><br>Because one is assignment while the other is equality t=
esting. They&#39;re two different things.<br><br>Why is that hard to explai=
n?<br><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r"><div><div></div><div><br></div><b>But this is actually relatively easy t=
o explain why it&#39;s not working</b>:</div><div><div style=3D"background-=
color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bor=
der-width:1px;word-wrap:break-word"><code><div><font color=3D"#660066"><spa=
n style=3D"color:#008">if</span><span style=3D"color:#660">({-</span><span =
style=3D"color:#066">1</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">-</span><span style=3D"c=
olor:#066">1</span><span style=3D"color:#660">}</span><span style=3D"color:=
#000"> </span><span style=3D"color:#660">=3D=3D</span><span style=3D"color:=
#000"> p</span><span style=3D"color:#660">)</span><span style=3D"color:#000=
"> </span><span style=3D"color:#008">return</span><span style=3D"color:#660=
">;</span></font></div></code></div><br></div></div></blockquote><div><br>U=
m, no. If we allow `X =3D=3D Y` to work, then it makes sense that we allow =
`Y =3D=3D X` to work. To disallow one and not the other is far more bizarre=
 than allowing one operation but forbidding a completely different one. <br=
><br></div><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"><d=
iv></div><div><b>Bonus:</b></div><div>This must work, it really must work:<=
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><fon=
t color=3D"#660066"><span style=3D"color:#008">const</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#008">auto</span><span style=3D"col=
or:#000"> e </span><span style=3D"color:#660">=3D</span><span style=3D"colo=
r:#000"> car </span><span style=3D"color:#660">?</span><span style=3D"color=
:#000"> car</span><span style=3D"color:#660">-&gt;</span><span style=3D"col=
or:#000">engine</span><span style=3D"color:#660">()</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#660">:</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">{};</span></font></div></code></div=
>=C2=A0We know it does not but it should, no reason why not - first arg is =
given, second arg is given, the the third must the same type as the second,=
 so we have everything to deduce it!</div></div></blockquote><div><br>Again=
, that goes back to consistency. `!car ? {} : car-&gt;engine()` is conceptu=
ally the same, yet it wouldn&#39;t work under your scheme.<br></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/0e27bc76-eada-4d70-80d7-b91b5a2d5767%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0e27bc76-eada-4d70-80d7-b91b5a2d5767=
%40isocpp.org</a>.<br />

------=_Part_412_1619274301.1474204088557--

------=_Part_411_1138377791.1474204088556--

.
