220 37643 <0f06146e-ae61-4c74-b09d-07dae4aa058f@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: Variable declaration in a ternary conditional
Date: Wed, 4 Apr 2018 11:41:39 -0700 (PDT)
Lines: 77
Approved: news@gmane.org
Message-ID: <0f06146e-ae61-4c74-b09d-07dae4aa058f@isocpp.org>
References: <8a755089-c146-47ab-8250-c2b3e705cacd@isocpp.org>
 <HayhuYBDuyAEh15N8sBKgh2-1yZsNQ43kbPFwb5tFXZGfNsR6LJNDl6YnmC6scpv2JSgvr-SBOp8lteU_uVfy1Ck6ETX347kh-9KDhIzld4=@miator.net>
 <3cdd7b2c-3716-4a58-8a13-3f65fb2eae22@isocpp.org> <CALvx3hYWiya5qW1dVXGc7dc1V9KKLgLcdV=YyqFuUDUHsWxcgQ@mail.gmail.com>
 <9fabc312-9500-4b34-9a4a-a2793891c585@isocpp.org> <CALvx3hbdffFk56rX5AdDPZA18PjpyUdKjpZX84C9JN5kaiBkRg@mail.gmail.com>
 <CALvx3hYbzDwMFc5VnS5Da4G-WT7QB+P0H2oQ9ZG3eXAyV36ocw@mail.gmail.com>
 <d772dfc9-cd4e-45fa-87e3-9b91551cfdb5@isocpp.org> <CALvx3hbw+nwB0iKdu0p+DqNcT2eTrz2gTb5pHzrf-=VcjiSBow@mail.gmail.com>
 <820d844c-21a7-429c-bf55-17ee12f8ca8e@isocpp.org> <CAANG=kX5nk=tVyY1fvzFppy8XEcqxMTtAh_PMSGHHiE=cgXQZw@mail.gmail.com>
 <2fe5d081-e13f-4750-87b0-a3b5b47eb252@isocpp.org> <CAANG=kWVYp=SyO3wkiSWYNTcZgTNwrB0FmZOKqPfACuZNgFDoA@mail.gmail.com>
 <CALvx3hYbx1X81NWBaS4o2ScsA+nuy=+gYWJirtN+ZdPgCP_0ug@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_8_870928626.1522867300023"
X-Trace: blaine.gmane.org 1522867177 11857 195.159.176.226 (4 Apr 2018 18:39:37 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 4 Apr 2018 18:39:37 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBZFYSTLAKGQETQPCERY@isocpp.org Wed Apr 04 20:39:32 2018
Return-path: <std-proposals+bncBCEKFTV6ZUMBBZFYSTLAKGQETQPCERY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f69.google.com ([209.85.213.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBZFYSTLAKGQETQPCERY@isocpp.org>)
	id 1f3nJk-00030Y-Em
	for gclcip-std-proposals@m.gmane.org; Wed, 04 Apr 2018 20:39:32 +0200
Original-Received: by mail-vk0-f69.google.com with SMTP id d72sf9118838vkf.4
        for <gclcip-std-proposals@m.gmane.org>; Wed, 04 Apr 2018 11:41:42 -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
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=uNUbEr+WkzrYTWkGf5PdfSG4UAI8FTL+dyLx7c8IYoI=;
        b=VPkQor7Q2Lgxa7NBjuTGtwHOr5qBvE3zE5y0esdXi4UxZM0G5V2iiEXPqGL5ajth+p
         hrBJN6bnDKI5Bjhq3puGcx4E0hKFFjejRDfcgEzhzntYAxrolIy2L+Q4XiQemvBXGFUc
         CVyNPlibvR3ZAoYKH1ZvrrUzvfgEehzDBd7SAWkzPSBJbdv4d6NR+V79erGUeLKWHx3X
         sh4q1LrAgsvIiSks7naUhcQYStSSNxd4a3/hvlWeC1lOqo0PxE0Ep2XV0dad0VeOEeVF
         oiGrzkkaTTLkRiLkQSEXVqEzcrKOtXHTUCLB7pMBSHckq+QQTre+QaJRG5GIM2LJCL4M
         oRKA==
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
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=uNUbEr+WkzrYTWkGf5PdfSG4UAI8FTL+dyLx7c8IYoI=;
        b=qvW7e7IOI7d400iuChz0m67AoQRY+juN5cSWRE9e4JgsTNbux524tb1PoLqm8nDMFz
         TC27t6d6mXPmE5HLCCDtBvsuQqTtbNdydDeG37gGMdNohQ32VUQnsJvvwIzAE6shn9kI
         ek7+HcEUTDn55aze5ZImhPHy+iB/mCwjEKmSjKiR8RIqZpOPb2CKbcyvr7gN9aWIZ5Dl
         JwjSJD1HWqgBmCz1jHCjL3gMp/xIfr0sh5Gi5vANK6p+0TGziKwzb4AoQmeY6hdB0zU3
         iqovq+UkCcJY07KHZECIvL8z7UgabogXZ0hWEoHZ3AfBB5/uoTDyX8NrjLh2t7jZNH79
         8PUg==
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=uNUbEr+WkzrYTWkGf5PdfSG4UAI8FTL+dyLx7c8IYoI=;
        b=sBHwtZdUfqdtfYR3OhehnEKA97U5Si3hJhQVDxhJlvf/UfrNV+CPlz8ZivadrGaAr5
         tlvttlfNSDZR3WjfgwH+IbLK1fatcpk1/b4YYqoO5kNQmVF4O4uI3g0EcJtVhqnQqYvm
         kbzIqtBUpOgX3s68tKEHNXlr4CPqc0fQltNDGEoStTjiYeBeLNBLrUteWnNnUkUjl70i
         CzABbLEHw4g4UfOnzy8SPAFwJQgWU72H7d1sO2he2eq6hRqBXmG4UwBPograp/m4+TJO
         yUACWNE3bMMS/6m4TMLZWIF2twRfRAn4ojRDfRmCkBeOTii5FCGvq6FhL/dKSwv3KqYo
         Leeg==
X-Gm-Message-State: ALQs6tDrrvnJT8G6e+aaLob1NNl92jc0I8/KUpYoOElxMwO4aAZMbHvY
	pWbjNB5OkxAr2FisyEBD+oahmQ==
X-Google-Smtp-Source: AIpwx49i3qY6hhnKSP/OSQ8GcA6hbebL6ucs+f0t6pGfG0xOZzhmeZ4si/veOTE4yL/wjBYG3DaEEQ==
X-Received: by 10.176.36.21 with SMTP id f21mr7866658uan.125.1522867301874;
        Wed, 04 Apr 2018 11:41:41 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.31.162.133 with SMTP id l127ls2093775vke.13.gmail; Wed, 04 Apr
 2018 11:41:40 -0700 (PDT)
X-Received: by 10.31.140.138 with SMTP id o132mr2353554vkd.8.1522867300500;
        Wed, 04 Apr 2018 11:41:40 -0700 (PDT)
In-Reply-To: <CALvx3hYbx1X81NWBaS4o2ScsA+nuy=+gYWJirtN+ZdPgCP_0ug@mail.gmail.com>
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-Spam-Checked-In-Group: 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:37643
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/37643>

------=_Part_8_870928626.1522867300023
Content-Type: multipart/alternative; 
	boundary="----=_Part_9_1337700500.1522867300023"

------=_Part_9_1337700500.1522867300023
Content-Type: text/plain; charset="UTF-8"



On Wednesday, April 4, 2018 at 2:23:43 PM UTC-4, Richard Hodges wrote:
>
> Just a thought, but how badly would it mangle the language if the if 
> keyword, as well as introducing a statement, was also able to introduce an 
> expression which returned:
>
> * In the case where there is an else clause:  the std::common_type of its 
> true and false clauses
> * In the case where there is no else clause: a std::optional<T> where T is 
> the expression type of the true case.
>

I don't like the idea of implicitly tying syntax into a standard library 
type like `optional` in this way. We should just require that 
if-expressions have an `else` clause.

Otherwise, the idea of an if-expression seems to be a solid one. This 
formulation also solves other problems; since it uses `if` as an 
introducer, it can use `if constexpr` as an introducer as well for 
`constexpr` initializations.

-- 
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/0f06146e-ae61-4c74-b09d-07dae4aa058f%40isocpp.org.

------=_Part_9_1337700500.1522867300023
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Wednesday, April 4, 2018 at 2:23:43 PM UTC-4, R=
ichard Hodges 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">Just a thought, but how badly would it mangle the language if the =
<font face=3D"monospace, monospace">if</font> keyword, as well as introduci=
ng a statement, was also able to introduce an expression which returned:<br=
><br>* In the case where there is an else clause:=C2=A0 the std::common_typ=
e of its true and false clauses<br>* In the case where there is no else cla=
use: a std::optional&lt;T&gt; where T is the expression type of the true ca=
se.<br></div></blockquote><div><br>I don&#39;t like the idea of implicitly =
tying syntax into a standard library type like `optional` in this way. We s=
hould just require that if-expressions have an `else` clause.<br><br>Otherw=
ise, the idea of an if-expression seems to be a solid one. This formulation=
 also solves other problems; since it uses `if` as an introducer, it can us=
e `if constexpr` as an introducer as well for `constexpr` initializations.<=
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/0f06146e-ae61-4c74-b09d-07dae4aa058f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0f06146e-ae61-4c74-b09d-07dae4aa058f=
%40isocpp.org</a>.<br />

------=_Part_9_1337700500.1522867300023--

------=_Part_8_870928626.1522867300023--

.
