220 20786 <ef9b670a-512e-4911-a39e-40a814cf68ba@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Null -conditional and -coalescing operators
Date: Thu, 24 Sep 2015 12:51:02 -0700 (PDT)
Lines: 135
Approved: news@gmane.org
Message-ID: <ef9b670a-512e-4911-a39e-40a814cf68ba@isocpp.org>
References: <4c3e2ee7-2159-4e93-a439-7d5c94c38c9c@isocpp.org> <CANPtknyyW8iV=ANeHpHvmZxS_mpxHPWcgEmCa4wLf+RugN2xDw@mail.gmail.com>
 <mu11oa$vmq$1@ger.gmane.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1062_489372124.1443124262460"
X-Trace: ger.gmane.org 1443124267 22605 80.91.229.3 (24 Sep 2015 19:51:07 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 24 Sep 2015 19:51:07 +0000 (UTC)
Cc: mwoehlke.floss@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBKFISGYAKGQEODDQMCI@isocpp.org Thu Sep 24 21:51:06 2015
Return-path: <std-proposals+bncBCEKFTV6ZUMBBKFISGYAKGQEODDQMCI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f200.google.com ([209.85.214.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBKFISGYAKGQEODDQMCI@isocpp.org>)
	id 1ZfCXq-0006Ds-0B
	for gclcip-std-proposals@m.gmane.org; Thu, 24 Sep 2015 21:51:06 +0200
Original-Received: by obbgf5 with SMTP id gf5sf117991082obb.3
        for <gclcip-std-proposals@m.gmane.org>; Thu, 24 Sep 2015 12:51:05 -0700 (PDT)
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:content-type: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=0EV0eGM/uC+twI3WHM/Gl+Li66BqhrqE/XdfJN/ktEw=;
        b=gkOpakzA6Ys2Ds3bIcIJRLOYVilTjyW2/uSvjlwbKgmWzBxouioJNR+Yms0gKsOrrx
         ushoqxudgKY14OScZetlCVWKEn0Ht2GY+AtPqBTzhjFuNYunzKjr4Z3B8ajLpbAKxaoV
         tH3BMLYVjUU13Y9ZS3f9JLqf6Vw5R0BBvtqgg3SIWp9KNkKleNjSoTMrkG1cplTdt9Tp
         MiuxMxrHm9j24srGbu8BHbel07qwCMTOF1X2vtvAXJzY1rladTorCP6X/cFUeJMEoLZT
         skeHQm3g9xra13SDQMucHU047qGT0WO7pW9Kr3mQNYPZ3lFTQ3IrVOStmCt607DT/CHH
         55Fg==
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:content-type: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=0EV0eGM/uC+twI3WHM/Gl+Li66BqhrqE/XdfJN/ktEw=;
        b=TddwnITorUi/T4e+iwDY/C6QT98LEKQmzjptDaZT/lmHaiZBW9A1o7YA9YGkCuxDXy
         adyC+2Lvzq8tzHDo4F4MzS4gvKh+n/+hOowWXU+CAxJqp7WiR+xcGzI5d50ocoTgG6X3
         No3K7HUm1QESfUcZ1qvRTsM4YS6k0Cys4riBGdKnnXh2DzXeuwKTuMhFIlEWxvyFa261
         tU7xaBF0aICPTmP8mnOmlF3uKCQRRmxKTObMIqcTY1tG4oG08cAfgTYc5D9zKe51J7Sy
         lsRThn7f2fCpuH9QELareaR4x50AlNFeMTP3RD08XYut/7kgOzceoKpHiUDfoSD3BLSi
         3SBw==
X-Gm-Message-State: ALoCoQky+W/JNSB4K0fU79V3976IjNxEjJLi1yS4CAWkfnjt9nHFgIR2WjvVKr8kIzhwvFx/yhDS
X-Received: by 10.182.106.11 with SMTP id gq11mr1277519obb.25.1443124265027;
        Thu, 24 Sep 2015 12:51:05 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.60.34 with SMTP id e2ls19947igr.4.canary; Thu, 24 Sep 2015
 12:51:04 -0700 (PDT)
X-Received: by 10.50.117.4 with SMTP id ka4mr156772igb.6.1443124264338;
        Thu, 24 Sep 2015 12:51:04 -0700 (PDT)
In-Reply-To: <mu11oa$vmq$1@ger.gmane.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-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:20786
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/20786>

------=_Part_1062_489372124.1443124262460
Content-Type: multipart/alternative; 
	boundary="----=_Part_1063_960156838.1443124262460"

------=_Part_1063_960156838.1443124262460
Content-Type: text/plain; charset=UTF-8

On Thursday, September 24, 2015 at 10:36:06 AM UTC-4, Matthew Woehlke wrote:

written += ?(stream)->write(buffer);
>

That brings up a question. Namely... what does that actually do?

What I mean is this: `?(stream)->write(buffer)` is an expression. What type 
does it resolve to? The general idea with these things is that they resolve 
to doing something or not doing something. And thus, is equivalent to:

if(stream) then stream->write(buffer)

But that's not an expression; that's a statement. Statements don't resolve 
to values.

So if the condition is false, what does the overall expression resolve to? 
Does it default-construct a value of the type that would result if the 
condition was true?

Or does the condition being false completely wipe out the entire statement. 
That is, even the += is part of the condition. If so, that requires 
look-ahead. Potentially *lots* of look-ahead.

?: makes it clear exactly what's going on:

written += stream ? stream->write(buffer) : 0;

(I'll note that part of the motivation here probably comes from wanting 
> to dodge draconian coding styles that mandate multiline braces around 
> ANY conditional body. Which, I'll be honest, I've done myself... 
> employed ugly hacks to dodge such, I mean; I personally loathe requiring 
> braces in single-statement conditional bodies.) 
>

That's a pretty poor motivation for a language feature.

-- 

--- 
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/.

------=_Part_1063_960156838.1443124262460
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Thursday, September 24, 2015 at 10:36:06 AM UTC-4, Matt=
hew Woehlke wrote:<br><br><blockquote style=3D"margin: 0px 0px 0px 0.8ex; b=
order-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmai=
l_quote">written +=3D ?(stream)-&gt;write(buffer);<br></blockquote><div><br=
>That brings up a question. Namely... what does that actually do?<br><br>Wh=
at I mean is this: `?(stream)-&gt;write(buffer)` is an expression. What typ=
e does it resolve to? The general idea with these things is that they resol=
ve to doing something or not doing something. And thus, is equivalent to:<b=
r><br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 2=
50); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1=
px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpr=
ettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">if</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">stream</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">then</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> stream</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">-&gt;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">write</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">buffer</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
</div></code></div><br>But that&#39;s not an expression; that&#39;s a state=
ment. Statements don&#39;t resolve to values.<br><br>So if the condition is=
 false, what does the overall expression resolve to? Does it default-constr=
uct a value of the type that would result if the condition was true?<br><br=
>Or does the condition being false completely wipe out the entire statement=
.. That is, even the +=3D is part of the condition. If so, that requires loo=
k-ahead. Potentially <i>lots</i> of look-ahead.<br><br>?: makes it clear ex=
actly what&#39;s going on:<br><br><div class=3D"prettyprint" style=3D"backg=
round-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-s=
tyle: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"pret=
typrint"><div class=3D"subprettyprint"><span style=3D"color: #000;" class=
=3D"styled-by-prettify">written </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">+=3D</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> stream </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">?</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> stream</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">-&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">w=
rite</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">buffer</span><s=
pan 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: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"=
styled-by-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">;</span></div></code></div><br></div><blockquote class=3D"gmail_=
quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;pa=
dding-left: 1ex;">(I&#39;ll note that part of the motivation here probably =
comes from wanting
<br>to dodge draconian coding styles that mandate multiline braces around
<br>ANY conditional body. Which, I&#39;ll be honest, I&#39;ve done myself..=
..
<br>employed ugly hacks to dodge such, I mean; I personally loathe requirin=
g
<br>braces in single-statement conditional bodies.)
<br></blockquote><div><br>That&#39;s a pretty poor motivation for a languag=
e feature.<br></div></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 />

------=_Part_1063_960156838.1443124262460--
------=_Part_1062_489372124.1443124262460--

.
