220 32560 <734764c8-e502-4635-be76-a76cab6261a1@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: relaxing rules for ternary operator. Allow
 incompatible types.
Date: Sun, 21 May 2017 10:35:10 -0700 (PDT)
Lines: 105
Approved: news@gmane.org
Message-ID: <734764c8-e502-4635-be76-a76cab6261a1@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>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_303_894290855.1495388110516"
X-Trace: blaine.gmane.org 1495388110 5134 195.159.176.226 (21 May 2017 17:35:10 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 21 May 2017 17:35:10 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBT47Q7EQKGQEX7IBYOI@isocpp.org Sun May 21 19:35:06 2017
Return-path: <std-proposals+bncBCEKFTV6ZUMBBT47Q7EQKGQEX7IBYOI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-it0-f70.google.com ([209.85.214.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBT47Q7EQKGQEX7IBYOI@isocpp.org>)
	id 1dCUl0-0001Eg-G3
	for gclcip-std-proposals@m.gmane.org; Sun, 21 May 2017 19:35:06 +0200
Original-Received: by mail-it0-f70.google.com with SMTP id s131sf79343928itd.6
        for <gclcip-std-proposals@m.gmane.org>; Sun, 21 May 2017 10:35:12 -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=dkxlge5mtxOjJ1O29IZgRBkQpFlaW3syS1hAalJQBaU=;
        b=G4l2Ww9j/7Ev4G3nga70FIOlw17TsZpw6MFE3oPZo4tZrij7b5XWS4eqXOXiJmYRZa
         Dk94Th7g4NHjPDm1sPXvfdXaIs8kUFF+QTS6TFRBBpG8k80ujP04XokufqT/RY4PPChm
         XfqWHeAzzDE/Rsc2PNrESlO0fCsbqn/KX2QhNzriSd06MpUBJAfGalBJnHj8pdT97Ntn
         lKkEzbR7EA7RAu6MCifdP0J4eYZXLnqJdzKqRTqN4JTt0YnaI9G4oenj3Dh69uRb/Ry+
         0mSmwhPpFviXL1gwNq0caNzEi/JcdMwZix/TJT7A5NkeKt+4Of+pakAR2kfh2PjcyQK6
         BtmA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        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=dkxlge5mtxOjJ1O29IZgRBkQpFlaW3syS1hAalJQBaU=;
        b=DuH55fyLWmOHo9TABQaScq6rSIQJINb7ZNUV1jtPIOwX2bkwma+8QpcNjceig1vk5T
         uUDWxBK2nCW+Nhm8qe+Hy8N1C7SjS63/ciZPwPhOj9EJbxq8oouPlH4TJFKzF0FTeOtZ
         c8xbbwInn33AHV1XkJeLLYDkB2GARFK0g8KpqtAT5/BClSoNO0j0AH1UEf3zeo7/U1nj
         12YvQylg6goCu88Fmwek9xkF3Q+xszl1XuFjBdsIkAhwTd4VsJ7eFBv3OeTO56ecTkRp
         rYVdSApdq8MjHNOXyQweQ6ax9c1DGBvo8cF6qy6E7ijrGBXoahY6k6s7CIhRt1M6LiTH
         YvmA==
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=dkxlge5mtxOjJ1O29IZgRBkQpFlaW3syS1hAalJQBaU=;
        b=gK8YngcTLSnXJZs0uSLzlEj/+SoR0XBrynJZQXOiGeId/vlLqjAoT7grMuK3LNoAh7
         2RQIYChBVKRSLByeoLJF8YWVnv3hQo4bjnzaGNc0qZ1ivpzA8eRREC1jq6MGd9tQL7BL
         FVS+DkqVPx+gtzTCOjcnJxyAyrBWIBx79RTr5GLNQhpRO70JygqMTuyIX9RLiOOA02w0
         8qNe4y96zbQpBqBON20+pb/6dV9qe2Y35Bxwn/xMimr+eI23PhHZAFxDanI568gfEBfs
         /Zgo1vQkSLhFEm/Ivk9vSDEdikZhFTSffFZgAGjtBR7AOZdTSCuGODCw6TrlKR2Y0Yr+
         YPQw==
X-Gm-Message-State: AODbwcCRJIfpkaO/6gX1TYfu+B/P10maNZvO29R5b+X/yDQBpRU7w3e+
	Q9jn6/MbsncsFCmv
X-Received: by 10.36.160.197 with SMTP id o188mr7773256ite.3.1495388111783;
        Sun, 21 May 2017 10:35:11 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.66.20 with SMTP id q20ls2248056ote.31.gmail; Sun, 21 May
 2017 10:35:11 -0700 (PDT)
X-Received: by 10.157.48.161 with SMTP id s33mr378163otc.1.1495388110997;
        Sun, 21 May 2017 10:35:10 -0700 (PDT)
In-Reply-To: <27694795.c6R7qxKFE5@tjmaciei-mobl1>
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:32560
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32560>

------=_Part_303_894290855.1495388110516
Content-Type: multipart/alternative; 
	boundary="----=_Part_304_1952100850.1495388110517"

------=_Part_304_1952100850.1495388110517
Content-Type: text/plain; charset="UTF-8"

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 <javascript:> 
> 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/734764c8-e502-4635-be76-a76cab6261a1%40isocpp.org.

------=_Part_304_1952100850.1495388110517
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Sunday, May 21, 2017 at 1:08:21 PM UTC-4, Thiago Maciei=
ra wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: =
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On domingo, 21 de mai=
o de 2017 02:03:45 PDT <a href=3D"javascript:" target=3D"_blank" gdf-obfusc=
ated-mailto=3D"IHx54ZF6AwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#=
39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#=
39;;return true;">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>

<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/734764c8-e502-4635-be76-a76cab6261a1%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/734764c8-e502-4635-be76-a76cab6261a1=
%40isocpp.org</a>.<br />

------=_Part_304_1952100850.1495388110517--

------=_Part_303_894290855.1495388110516--

.
