220 32563 <d23a44b3-3286-4e0b-b48e-c72b77f465a3@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: ma.kalbfuss@web.de
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: relaxing rules for ternary operator. Allow
 incompatible types.
Date: Sun, 21 May 2017 14:03:05 -0700 (PDT)
Lines: 164
Approved: news@gmane.org
Message-ID: <d23a44b3-3286-4e0b-b48e-c72b77f465a3@isocpp.org>
References: <1b5ee8eb-53df-4e98-af2f-829c7bc2e5b2@isocpp.org> <9064929.QEV8q21eIZ@tjmaciei-mobl1> <99350a9e-0c6b-468d-9761-f2b2b052275e@isocpp.org>
 <27694795.c6R7qxKFE5@tjmaciei-mobl1>
 <734764c8-e502-4635-be76-a76cab6261a1@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2211_1635247880.1495400585179"
X-Trace: blaine.gmane.org 1495400587 19482 195.159.176.226 (21 May 2017 21:03:07 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 21 May 2017 21:03:07 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC7YTI72XQOBBCMBRDEQKGQE3X2ZKUI@isocpp.org Sun May 21 23:03:02 2017
Return-path: <std-proposals+bncBC7YTI72XQOBBCMBRDEQKGQE3X2ZKUI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pf0-f199.google.com ([209.85.192.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC7YTI72XQOBBCMBRDEQKGQE3X2ZKUI@isocpp.org>)
	id 1dCY0E-0004t1-6G
	for gclcip-std-proposals@m.gmane.org; Sun, 21 May 2017 23:03:02 +0200
Original-Received: by mail-pf0-f199.google.com with SMTP id a66sf102770513pfl.6
        for <gclcip-std-proposals@m.gmane.org>; Sun, 21 May 2017 14:03:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to: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=+Ym6e4mv+Md7DJl+eXl+U5X4+3H8Vnr0suX0eycm440=;
        b=S2NyE3ii3vl8iODMJNU/zMniSkT8z53UX3czGFInt+ihYQgYhH/5chQ5AHRhxAsey7
         9gqNdRMw+SIE2SpUxHclo5UsmBOrl0Ox+sy4f250bbr+HYJ+SBOiVXUxOD6F0RZjU5LD
         aYp50blLgaO92mebqoHSaKgpI1E9d7TaxVn6kPDl90QGFcFdDue16MFOfBkYftXTlHPC
         5EsOyqXfbsAAuEKNPrOHfpioBI/G7ZDyzzPqdDvWT/39r1vqTbP1VQzkRmapIwIPKZQE
         Bw4CUwIkzQKXHnDJUTIV52JS7qCQX1RsXZiUClZrtnZUgmryfcemKHDeoOay7+GT92Bb
         ZXdQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to: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=+Ym6e4mv+Md7DJl+eXl+U5X4+3H8Vnr0suX0eycm440=;
        b=tt8DdpontntsQSujOL4VGcvjVQrzyQEJD7EtyOa3kbl56vDKeduCVI9zOyZyNUxgcC
         wia2c1E+JSE/q56xe5xyrZa8bGoleO9k/sDt7aywJ5eA1Nt3WQqo07otGY9+h2HGjSsu
         bBpfOAz1xFMVJeTzo92d6fPz/bqVRvTfgTLnfDJCxxkxeAHTL8MJcEbmrbH2P2gtxGEf
         sUPbkzofRBHKCI63syncV8rsViJDZPFjwImXf1Dddzb52ZZIKP+a/KtTpYb3COPA5FOe
         P7Mk+VmpzDrX/k9+L44eEmewxzTM/lE9r2BA+BSN/MCmC1t10eTttVyqegwrA8BtTu8q
         bLjw==
X-Gm-Message-State: AODbwcDQ9js4C4ZlH55lpZCzfLqtbAal2Gp2uOo5MwTizA1Qz7NCf4fI
	8rBNG+bfGFAcnHKz
X-Received: by 10.99.47.130 with SMTP id v124mr9858390pgv.116.1495400586542;
        Sun, 21 May 2017 14:03:06 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.54.70 with SMTP id w64ls2606385otb.26.gmail; Sun, 21 May
 2017 14:03:05 -0700 (PDT)
X-Received: by 10.157.48.161 with SMTP id s33mr391259otc.1.1495400585714;
        Sun, 21 May 2017 14:03:05 -0700 (PDT)
In-Reply-To: <734764c8-e502-4635-be76-a76cab6261a1@isocpp.org>
X-Original-Sender: ma.kalbfuss@web.de
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:32563
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32563>

------=_Part_2211_1635247880.1495400585179
Content-Type: multipart/alternative; 
	boundary="----=_Part_2212_1983742866.1495400585180"

------=_Part_2212_1983742866.1495400585180
Content-Type: text/plain; charset="UTF-8"

Mabe you're right. Another operator could be a better choice. But I'm still 
unsure about it. Another approach is to use an attribute to disallow 
genericity.


auto x = runtime_condition [[non generic]] ? A{} : B{};

or vice versa

auto x = runtime_condition [[generic]] ? A{} : B{};



It would be interesting to know, if there are other places where the same 
technique could be applied. Maybe for different return types of function 
calls, depeding on the passed arguments. I have to explore that.

Am Sonntag, 21. Mai 2017 19:35:10 UTC+2 schrieb Nicol Bolas:
>
> On Sunday, May 21, 2017 at 1:08:21 PM UTC-4, Thiago Macieira wrote:
>>
>> On domingo, 21 de maio de 2017 02:03:45 PDT ma.ka...@web.de wrote: 
>> > The code, following the ternary statement is moved into a generic 
>> lambda. 
>> > auto x = runtime_condition ? A{} : B{}; 
>> > 
>> > The generic lambda is instantiated two times, for each branch. 
>> Depending on 
>> > runtime_condition, 
>> > only one instance is executed. The statement 
>>
>> You do realise this grows exponentially, right? 
>>
>>         auto x = runtime_condition ? A{} : B{}; 
>>         auto y = runtime_condition ? C{} : D{}; 
>>         auto z = runtime_condition ? E{} : F{}; 
>>         x.f() + y.f() + z.f(); 
>>
>> There are 8 different branches there to make the above work. 
>>
>
> This is one of the reasons why I think, if we're going to do this, then it 
> *needs* to be a different operator from ?:. Something where you can 
> clearly see that you're invoking this implicit template stuff.
>
> And like I said elsewhere, I get the feeling that there is more to this 
> implicit template instantiation than there first appears. This seems almost 
> like pattern matching, but done implicitly via template instantiation, 
> rather than explicitly through some kind of switch statement.
>

-- 
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/d23a44b3-3286-4e0b-b48e-c72b77f465a3%40isocpp.org.

------=_Part_2212_1983742866.1495400585180
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Mabe you&#39;re right. Another operator could be a better =
choice. But I&#39;m still unsure about it. Another approach is to use an at=
tribute to disallow genericity.<br><br><br><div style=3D"background-color: =
rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; =
border-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code =
class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #=
008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> x </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> runtime_condition </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">[[</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">non generic</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">]]</span><span style=3D"color: #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"> A</spa=
n><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: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> B</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">{};</span></div></code></div><br>or vice versa<br=
><br><div style=3D"background-color: rgb(250, 250, 250); border-color: rgb(=
187, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: brea=
k-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"su=
bprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">aut=
o</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> x </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> runtime_condition </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">[[</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">generic</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">]]</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">?</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> A</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">{}</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </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"styled-by-prettify">{};</span></div></=
code></div><br><br><br>It would be interesting to know, if there are other =
places where the same technique could be applied. Maybe for different retur=
n types of function calls, depeding on the passed arguments. I have to expl=
ore that.<br><br>Am Sonntag, 21. Mai 2017 19:35:10 UTC+2 schrieb Nicol Bola=
s:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;b=
order-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">On Sunday, =
May 21, 2017 at 1:08:21 PM UTC-4, Thiago Macieira wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex">On domingo, 21 de maio de 2017 02:03:45 PDT <a rel=
=3D"nofollow">ma.ka...@web.de</a> wrote:
<br>&gt; The code, following the ternary statement is moved into a generic =
lambda.
<br>&gt; auto x =3D runtime_condition ? A{} : B{};
<br>&gt;=20
<br>&gt; The generic lambda is instantiated two times, for each branch. Dep=
ending on
<br>&gt; runtime_condition,
<br>&gt; only one instance is executed. The statement
<br>
<br>You do realise this grows exponentially, right?
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D runtime_cond=
ition ? A{} : B{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto y =3D runtime_cond=
ition ? C{} : D{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto z =3D runtime_cond=
ition ? E{} : F{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0x.f() + y.f() + z.f();
<br>
<br>There are 8 different branches there to make the above work.
<br></blockquote><div><br>This is one of the reasons why I think, if we&#39=
;re going to do this, then it <i>needs</i> to be a different operator from =
?:. Something where you can clearly see that you&#39;re invoking this impli=
cit template stuff.<br><br>And like I said elsewhere, I get the feeling tha=
t there is more to this implicit template instantiation than there first ap=
pears. This seems almost like pattern matching, but done implicitly via tem=
plate instantiation, rather than explicitly through some kind of switch sta=
tement.<br></div></div></blockquote></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/d23a44b3-3286-4e0b-b48e-c72b77f465a3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d23a44b3-3286-4e0b-b48e-c72b77f465a3=
%40isocpp.org</a>.<br />

------=_Part_2212_1983742866.1495400585180--

------=_Part_2211_1635247880.1495400585179--

.
